You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
The text was updated successfully, but these errors were encountered:
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:
The text was updated successfully, but these errors were encountered: