Popupmenu always grabs focus


I’m working on VST/AU which has a couple of comboboxes and popup menus.
When clicked on, the keyboard focus of my DAW is lost.
The “Plugin Editor Required Keyboard Focus” is disabled in my project settings.
I tried messing around with setWantsKeyboardFocus(false), setMouseClickGrabsKeyboardFocus(false) and Component::unfocusAllComponents().
I also tried setting the lookandfeel getMenuWindowFlags() for the popup menu with ComponentPeer::windowIgnoresKeyPresses. The function is called when the popup shows up, still no luck.

How do I prevent the popupmenu from grabbing focus?


I suspect the answer is that it’s a separate OS window. Try attaching the PopupMenu to a component rather than having it appear on the desktop. See PopupMenu::Options

1 Like