Make any Component lose keyboard focus when user clicks "outside"


#1

Hi,

I’d like the widgets in my (desktop) app to behave like in many other audio apps, where clicking somewhere outside the component that has focus (i.e. a TextEditor) makes it lose focus.
How would one go about doing this?

For example if I edit the rate of a parameter in a TextEditor, then click somewhere else in the window, the focus should go away. But this “somewhere else” could very well be another component that already catches right clicks (like a Track). So I’d like to avoid having to modify every existing “container” component that could catch a left click… is that possible?

cheers


#2

Does simply calling setWantsKeyboardFocus (true) on your background components do the trick?