window_has_focus

Returns if the game window is in focus or not.

Syntax:

GML Code Example

window_has_focus();


Returns: Boolean


Description

With this function you can poll the window (or tab) state and if it loses focus the function will return false otherwise it will return true. In most cases you can simply use the os_is_paused function to test this, but in some very specific cases (for example games on Chrome Apps) that function will not trigger, in which case you should use this function instead.

NOTE: This function is only valid for the HTML5, Windows 8 (JS), and Tizen (JS) modules.


Example:

GML Code Example

if !window_has_focus()
    {
    scr_PauseGame();
    }
 

The above code will check to see if the game window is in focus or not, and if the function returns false a script will be called.





No Examples Submitted

Does this page need better examples? Be the first to Submit

No Edits Suggested

Is this page unclear or not descriptive enough? Suggest an edit to the page and with enough upvotes your changes will be made.

No Questions Have Been Ask

Do you have a question about this page? Ask it Here