Hi all,
is there a way to disable keyboard focus for a component and all its child components (buttons, sliders, etc) at once and for good? At the moment, when I click on a button in a plugin window, it will have keyboard focus and when I press enter for example, it will trigger the button instead of controlling the DAW.
thanks,
Stefan
Component::setWantsKeyboardFocus()
Component::setMouseClickGrabsKeyboardFocus()
Search the Component class for all sorts of focus related functions.
If you want to unfocus everything all at once, there is:
Component:unfocusAllComponents()
Nevermind, I found the issue.
I’m using a PreferencesPanel
and every page is rebuilt when opening. Therefore I had to use a KeyboardFocusTraverser on every settings page individually. Using that code finally did the trick:
auto focusTraverser = Component::createKeyboardFocusTraverser();
auto comps = focusTraverser->getAllComponents(this);
for (auto& comp : comps) {
comp->setWantsKeyboardFocus(false);
comp->setMouseClickGrabsKeyboardFocus(false);
}
Thanks anyway
Stefan