Skip to content

Commit

Permalink
FlxDebugger: fix useSystemCursor and visible not being restored properly
Browse files Browse the repository at this point in the history
related to HaxeFlixel#1775
  • Loading branch information
Gama11 authored and Aurel300 committed Apr 17, 2018
1 parent 9e798a3 commit 2a8423b
Showing 1 changed file with 22 additions and 8 deletions.
30 changes: 22 additions & 8 deletions flixel/system/debug/FlxDebugger.hx
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,9 @@ class FlxDebugger extends Sprite

private var _windows:Array<Window> = [];

private var _wasMouseVisible:Bool = true;
private var _wasUsingSystemCursor:Bool = false;

/**
* Instantiates the debugger overlay.
*
Expand Down Expand Up @@ -445,24 +448,35 @@ class FlxDebugger extends Sprite
/**
* Mouse handler that helps with fake "mouse focus" type behavior.
*/
private inline function onMouseOver(_):Void
private function onMouseOver(_):Void
{
hasMouse = true;
#if !FLX_NO_MOUSE
FlxG.mouse.useSystemCursor = true;
#end
showCursor();
}

/**
* Mouse handler that helps with fake "mouse focus" type behavior.
*/
private inline function onMouseOut(_):Void
private function onMouseOut(_):Void
{
hasMouse = false;

restoreCursor();
}

private function showCursor():Void
{
#if !FLX_NO_MOUSE
_wasMouseVisible = FlxG.mouse.visible;
_wasUsingSystemCursor = FlxG.mouse.useSystemCursor;
FlxG.mouse.useSystemCursor = true;
#end
}

private function restoreCursor():Void
{
#if !FLX_NO_MOUSE
if (!FlxG.vcr.paused)
FlxG.mouse.useSystemCursor = false;
FlxG.mouse.useSystemCursor = _wasUsingSystemCursor;
FlxG.mouse.visible = _wasMouseVisible;
#end
}

Expand Down

0 comments on commit 2a8423b

Please sign in to comment.