Chrome plated onblur listening app?

Are there event listeners for the chrome-packed application to find out if the application has lost focus? I'm trying to make a game, but I can't get it to pause when I change focus.

I tried several different things, such as the following, but no one works.

document.onblur = pause; document.addEventListener('blur', pause, false); canvas.onblur = pause; canvas.addEventListener('blur', pause, false); window.onblur = pause; window.addEventListener('blur', pause, false); chrome.app.window.onblur = pause; chrome.app.window.onBlur = pause; chrome.app.window.onblurred = pause; chrome.app.window.onBlurred = pause; chrome.app.window.addEventListener('blur', pause, false); chrome.app.window.current().onblur = pause; chrome.app.window.current().onBlur = pause; chrome.app.window.current().onblurred = pause; chrome.app.window.current().onBlurred = pause; chrome.app.window.current().addEventListener('blur', pause, false); 

Any ideas? I can literally copy this entire list into my code, and not one pauses.

I am lost and Google has 3 results with some unrelated things, and then with missed work that I consider important.

+3
source share
1 answer

AppWindow is just a chrome-specific api that provides only the methods defined in the documentation. If you want to use standard events from a regular html window object, you must first get it using the contentWindow property of AppWindow . Example:

 chrome.app.window.current().contentWindow.onblur = function(){console.log("blur")}; 
+7
source

All Articles