Imagine you have a dialog with a few buttons in the content, but also an OK and Cancel button at the bottom. Usually you can confirm such dialogs with the return key.
But how does one trigger the other buttons using the keyboard? On Windows the convention is to press space bar to ‘click’ the button and return to confirm the dialog. Juce buttons however by default call their click handler on pressing return.
Now we have 2 conflicting uses in dialogs. Pressing return will at once both trigger the button in focus and confirm the dialog.
This is reproducible in the demo runner: Go to the dialogs demo, click alert window with extra components and put the keyboard focus on the dropdown. Press return. The dropdown will open, but the OK button will also go to the “pressed” state. Now press Tab. The dialog will close.
So, how does one implement a dialog window which can be used with the keyboard?