When we show a dialog box with DialogWindow::showModalDialog() the contentComponent do not have keyboard focus: User need to perform a mouse click to obtain it.
It’s because TempDialogWindow inherit form TopLevelWindow who does a setWantsKeyboardFocus (true) in its constructor.
A way to fix it is to setWantsKeyboardFocus (false) on the TempDialogWindow constructor or directly in DialogWindow::showModalDialog().
Another minor Keyboard focus issue is related to AlertWindow :
By default TextEditor created by AlertWindow::addTextEditor can have keyboard focus.
But non editable ComboBox created by AlertWindow::addComboBox cannot.
So the user can navigate between TextEditors with [tab] key but cannot do it with ComboBox components.
For example, it can be usefull when user what to change ComboBox selection with arrow keys.
It’s because ComboBox do not have setWantsKeyboardFocus (true) in it’s constructor like TextEditor class.
I understand that ComboBox::setEditableText behavior was an explanation of this exception.
I think it can be cool that AlertWindow::addComboBox activate the keyboard focus on non editable ComboBox by default,
preventing developer to add the following code in it’s AlertWindow child class.
I meant how to define a combobox that does not receive focus.
I can call SetWantsKeyboardFocus(false) after the ComboBox creation, but then if for any reason a lookAndFeelChanged() is issued, that setting is reverted to true.
Using a specialized focus traverser seems a bit too much for this. I’m currently calling SetWantsKeyboardFocus(false) again after a look and feel change, but it’s not an optimal solution.
I updated from juce v2 (one year old) to juce v3 (tip)
I don’t want keyboard focus on the combobox
The keyboard focus is there even if I declare setEditableText(false) and setWantsKeyboardFocus(false) on the ComboBox (using own LNF)
I don’t know what could have changed between v2 where it worked and v3 where it does not work anymore.
I discovered that It was solved by commenting out setWantsKeyboardFocus (! label->isEditable()); — just like hladik wrote.
You might want to have editable text but no keyboard focus, like in AAX plug-ins (tab, return and space must be transmitted to the host because this are DAW shortcuts). So, as these properties “editable” and “focus” are unrelated, I’d advise decoupling it. cc: Jules