From 38d5323c9dc6056b78fe5e3d1a5e4d092634e01a Mon Sep 17 00:00:00 2001 From: Mihai Alexandru <77043862+MAJigsaw77@users.noreply.github.com> Date: Tue, 1 Oct 2024 16:01:16 +0000 Subject: [PATCH] Attach `DEACTIVATE`/`ACTIVATE` events to `stage.nativeWindow`. (#3260) * Update FlxGame.hx * Fix for `flash` and `html5`. * Fix compatibility with `openfl` `9.2.2`. --- flixel/FlxGame.hx | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/flixel/FlxGame.hx b/flixel/FlxGame.hx index ef686a0e09..3dd97089d1 100644 --- a/flixel/FlxGame.hx +++ b/flixel/FlxGame.hx @@ -358,6 +358,9 @@ class FlxGame extends Sprite #if (desktop && openfl <= "4.0.0") stage.addEventListener(FocusEvent.FOCUS_OUT, onFocusLost); stage.addEventListener(FocusEvent.FOCUS_IN, onFocus); + #elseif (sys && openfl >= "9.3.0") + stage.nativeWindow.addEventListener(Event.DEACTIVATE, onFocusLost); + stage.nativeWindow.addEventListener(Event.ACTIVATE, onFocus); #else stage.addEventListener(Event.DEACTIVATE, onFocusLost); stage.addEventListener(Event.ACTIVATE, onFocus); @@ -918,4 +921,4 @@ private class FlxIntroSplash extends FlxSplash FlxG.game._gameJustStarted = true; super.startOutro(onOutroComplete); } -} \ No newline at end of file +}