I have strange problem that is maybe not big deal but it irritating me.
I created audio plugin, and I have created combo box with my plugin’s presets.
And when I click combo box then popup menu appears. But when popup menu is showing and I click somewhere outside my plugin BUT within the plugin host, the popup menu doesn’t disappear. It happens both in Logic Pro X and in Juce Plugin Host.
And what is more annoying the popup menu is always on top. So even if I am in other plugin, the popup menu still appears on top.
I can even move the window of my plugin and popup menu is still there (doesn’t move with window plugin.
So to close popup menu I need:
chose something from menu or back to my plugin and click somewhere in my plugin but outside the popup menu. And third option is to click on keyboard “esc” but only if I am focused on my plugin window. And other option is to close the plugin. And last one is to click somewhere outside the plugin host.
And I can’t find anywhere the solution hot to set it properly. I want popup menu close any time I click outside of it (any where but outside the popup menu). Or at list set it to be not always on top of my plugin host.
Could anyone give some advice?
For any help great thanks in advance.
Yeah, that is annoying. One solution is to not use a ComboBox, but use a button that makes another component (that looks like a menu) visible. A bit of a pain if you want all the features of a menu, like sub-menus, but it does avoid this odd behavior.
Closing a menu when clicking somewhere outside the plugin itself requires somehow detecting that happening, and I’m not sure if hosts even pass that kind of information to the plug-in, let alone whether JUCE has any way to deal with it. Part of the joys of plug-in programming!
This could be fixed by giving a parent component to your ComboBox popup menus, with something like that in your lookandfeel :
Component* getParentComponentForMenuOptions (const PopupMenu::Options& options) override
if (auto* comp = options.getParentComponent())
if (auto* targetComp = options.getTargetComponent())
if (auto* editor = targetComp->findParentComponentOfClass<AudioProcessorEditor>())
return LookAndFeel_V4::getParentComponentForMenuOptions (options);
great thanks for your support.
OK, I am going to create my own component with presets list, as you suggested.
But to be honest I am not sure how to indicate that click is outside of that component.
Of course I know methods like
And my concept looks like that:
When I click on button (my own combo box as you sugested to be regular button) and in the listener of that button I will call
And now in the main window
juce::AudioProcessorEditor::mouseDown() I will check if coursor is outside of
myPresetsComponentWindow, and if it’s outside I will call
But here is the problem:
juce::AudioProcessorEditor::mouseDown() is called only within the bounds of
juce::AudioProcessorEditor but not outside of it (for examle other element of the plugin host). So my concept will not work.
So the question is how to call
mouseDown any time I click anywhere on the screen?
Or at least is there an method that is called when I lost focus on my
juce::AudioProcessorEditor. I tried to override method
focusLost() like that:
void focusLost(FocusChangeType cause) override
DBG("FOCUS LOST "));
But it is never called. I can’t figure it out when it is called.
Hey lalala!!! Great it looks like it solves all my problems. Thanks. It works. It’s not close the popup menu when I click outside the plugin. But it makes it not always on top, and it moves with window. It is great enaugh for me. Thanks one more time.