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

Keyboard focus bugs #4

Open
fpw opened this issue Sep 9, 2018 · 0 comments
Open

Keyboard focus bugs #4

fpw opened this issue Sep 9, 2018 · 0 comments

Comments

@fpw
Copy link

fpw commented Sep 9, 2018

Hi,

there are a few issues with keyboard focus:

  • the code uses io.WantCaptureKeyboard to decide whether to request keyboard focus from X-Plane. In VR, the keyboard focus makes a visual difference: The virtual keyboard is shown if and only if the window has focus. io.WantCaptureKeyboard is sometimes true even if keyboard input is not required. For example, when the keyboard could be used to navigate the GUI. I suggest to use io.WantTextInput when in VR so the keyboard is only shown when text is actually required.

  • when the code decides to give up the keyboard focus, it correctly resets io.KeysDown. However, it doesn't reset the special keys like io.KeyShift. I found this issue through a hard to debug bug in one of my plugins: If the user enters only uppercase characters in an input field, the GUI breaks. The reason was that the shift key is the last released key in this case and since that's not reset properly, the input field can never lose focus again, making the whole GUI unresponsive to clicks. This can be fixed by resetting the special keys.

  • the check for the flags in HandleKeyFuncCB has some issues:

    • when a key is pressed and held down, X-Plane sets the down flag on the first key only, i.e. this will only result in a single character even if the key is held. This can be fixed by checking for the flag being "not up" instead of down.
    • when special keys like shift and ctrl are pressed simultaneously, the code will not set any of them to active because the bit and is compared with a single key only. I suggest to compare the result of the and != 0 instead of == mask.
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

No branches or pull requests

1 participant