flixel icon indicating copy to clipboard operation
flixel copied to clipboard

Mouse is visible after `FlxG.mouse.visible=false` if the game starts unfocused

Open raulfpl opened this issue 6 years ago • 1 comments

  • Haxe version: 4.0.0-rc.5
  • Flixel version: 4.6.3 (this bug is also present in current dev branch)
  • OpenFL version: 8.9.5
  • Lime version: 7.6.3
  • Affected targets: html5 (at least)

Code snippet reproducing the issue:

package;

import flixel.FlxState;
import flixel.FlxG;

class PlayState extends FlxState
{
	override public function create():Void
	{
		super.create();
		FlxG.mouse.visible = false;
	}
}


Observed behavior: When starting the game in html5 target, if you click the navigation bar before the game loads and then click the game after the game started, the cursor will show even if you ran FlxG.mouse.visible = false on your state create() function.

Expected behavior: The cursor should remain hidden.


The reason that happens is because FlxMouse.onFocus() uses visible = _visibleWhenFocusLost; and that function is called before a call to onFocusLost() which should set the _visibleWhenFocusLost field to the value visible had before, and the initial value for _visibleWhenFocusLost is true.

One possible way to fix this is to change the value of _visibleWhenFocusLost to the value of in thevisible` property setter.

raulfpl avatar Oct 24 '19 14:10 raulfpl

Yes I've had this same issue, fixed it by adding this line to my project.xml: <haxedef name="FLX_NO_MOUSE" if="desktop" />

Below all the other haxedefs

RichardBray avatar Jun 15 '20 16:06 RichardBray