window_has_focus

Returns if the game window is in focus or not.

Syntax:

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, and MacOS modules.


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.


Back: The Game Window
Next: window_device
© Copyright YoYo Games Ltd. 2018 All Rights Reserved