Created
February 25, 2014 05:48
-
-
Save b1rdex/9203433 to your computer and use it in GitHub Desktop.
node-webkit window.isFocused emulation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function() { | |
window.frame = require("nw.gui").Window.get(); | |
window.frame.isFocused = true; | |
var windowFocusHandler = function() { | |
window.frame.isFocused = true; | |
} | |
, windowBlurHandler = function() { | |
window.frame.isFocused = false; | |
} | |
; | |
window.frame.on("focus", windowFocusHandler); | |
window.frame.on("blur", windowBlurHandler); | |
window.addEventListener("focus", windowFocusHandler); | |
window.addEventListener("blur", windowBlurHandler); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment