There are in general a few issues with keyboard events. Checkout
develop and modify the HelloWorld example as follows:
Now we can observe 2 bugs:
After starting you can’t interact with the window using the keyboard. You have to click on the window first. The same occurs after you minimize using the minimize button and restore using the taskbar. The only exception are button shortcuts.
The OK button has
returnKeyas its shortcut (which is a common setup in dialog boxes). Now bring the keyboard focus to the toggle button, and press return:
- Normally the return key will trigger a button click on a button (so the toggle button will change state).
- But observe how both the toggle button will change state, and the OK button click will be triggered.
The button shortcuts are an example of events handled using the
keyStateChanged callback. This can be quite surprising, since it allows parent components to handle events which are filtered out in the
keyPressed callback (by returning
false). And since
keyStateChanged doesn’t receive the changed key, it’s hard to filter out events there.
Any thoughts on how to handle this problem?