Skip to content

Instantly share code, notes, and snippets.

@b1rdex
Created February 25, 2014 05:48
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save b1rdex/9203433 to your computer and use it in GitHub Desktop.
Save b1rdex/9203433 to your computer and use it in GitHub Desktop.
node-webkit window.isFocused emulation
(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