Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed bug causing focus to be lost when pressing TAB. #2812

Closed

Conversation

EliteMasterEric
Copy link
Contributor

The associated bug can be reproduced in this way:

  • Build any project with FLX_DEBUG enabled.
  • While in-game, press TAB.

Expected behavior is that nothing should happen in-game (unless something is bound to TAB).

Actual behavior is that the window loses focus and the cursor becomes detached from the window.

The root cause is that the console textbox is being focused by OpenFL even when the debugger is not open.

Tested and with this fix the textbox still focuses when the debugger is OPEN (as expected).

@moxie-coder
Copy link
Contributor

I feel like I remember something like that happening before, and that can honestly be a bit of a pet peeve to people, so this is a good change ngl (I don't understand why it wasn't added sooner)

@Geokureli
Copy link
Member

nice I'll try this out today

flixel/system/debug/console/Console.hx Outdated Show resolved Hide resolved
flixel/system/debug/console/Console.hx Outdated Show resolved Hide resolved
@EliteMasterEric
Copy link
Contributor Author

@Geokureli Reworked the PR to cleanup style changes and only include the fix on Windows (where the bug is known to occur).

@Geokureli
Copy link
Member

Thanks, I still need to test this on my windows pc. Also when i press tab on mac it just crashes (tried on dev, btw) Was gonna see why, and see if this fixes that

@Geokureli
Copy link
Member

linking this as it seems related:
openfl/openfl#1856

@@ -119,6 +119,9 @@ class Console extends Window
{
if (FlxG.debugger.visible && FlxG.game.debugger.console.visible && e.keyCode == Keyboard.TAB)
FlxG.stage.focus = input;
#if windows
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nitpicky, I know but please put an empty line above here. I always try to put one empty after an if's block

Suggested change
#if windows
#if windows

@Geokureli
Copy link
Member

Geokureli commented May 23, 2023

Also I tried these steps on my windows pc (without your changes):

Build any project with FLX_DEBUG enabled.
While in-game, press TAB.

the "actual behavior" you describe doesn't happen for me, not sure if it's because it's windows 11, I can try my win10 pc. But the system mouse appears when i press "~" revealing the debug menu, not when i press tab. My game doesn't lose focus in any way, i'm still able to control it.

@Geokureli
Copy link
Member

I wasn't seeing the issue because I didn't have hscript installed. with hscript installed I now see that pressing tab is a way to select the console input, which seems to pause the game. Unfortunately this change doesn't prevent that, and even clicking the console field pauses the game

@EliteMasterEric
Copy link
Contributor Author

EliteMasterEric commented May 24, 2023

Also I tried these steps on my windows pc (without your changes):

Build any project with FLX_DEBUG enabled.
While in-game, press TAB.

the "actual behavior" you describe doesn't happen for me, not sure if it's because it's windows 11, I can try my win10 pc. But the system mouse appears when i press "~" revealing the debug menu, not when i press tab. My game doesn't lose focus in any way, i'm still able to control it.

To clarify on the symptoms

If the debug menu is open, pressing TAB switches focus to the text field for the console.

If the debug menu is CLOSED, pressing TAB seems to switch focus to the inactive element causing focus to detach from Flixel entirely.

Pausing the game while in the debug view and typing in console seems to be the default and intended behavior to prevent inputs from affecting the game

@Geokureli
Copy link
Member

Geokureli commented May 24, 2023

If the debug menu is CLOSED, pressing TAB seems to switch focus to the inactive element causing focus to detach from Flixel entirely.

I tried this as well, and saw no issue on any of my machines. maybe it's because I didn't create any textFields?

could you try this in a new, small project and see if it still happens? and can you elaborate on the symptoms, more?

FYI, I know this is a real issue, we had to change a hotkey in our editor from tab because people were having issues. I just can't merge anything until I know what's happening. I also want to test FlxInputText to see if this effects that

@NeeEoo
Copy link
Contributor

NeeEoo commented May 24, 2023

I thought #2760 fixed this issue

@Geokureli
Copy link
Member

Geokureli commented May 24, 2023

@EliteMasterEric can you try and confirm that the issue is still happening to you on the latest release? not sure if you made this branch based on your experiences prior to upgrading to flixel 5.3. especially since I cannot reproduce the error

@EliteMasterEric
Copy link
Contributor Author

@EliteMasterEric can you try and confirm that the issue is still happening to you on the latest release? not sure if you made this branch based on your experiences prior to upgrading to flixel 5.3. especially since I cannot reproduce the error

It looks like I was on an old branch and hadn't fast-forwarded. The issue appears to be resolved now.

@Geokureli
Copy link
Member

Thanks for clearing things up @NeeEoo

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants