I’ve been looking for a solution to this issue for almost a year now! To my knowledge, there are 3 problems with running Popup Menus asynchronously (what is recommended for plugins).
As mentioned in this thread, moving the plugin window via dragging from the title bar does not dismiss open popup menus. The solution to make the popup a child of the plugin editor solves part of the problem but creates new ones when considering that it is now constrained to the bounds of the plugin editor. Displaying a large menu from a small plugin will frustrate users as they will have to scroll to find the option they want rather than seeing everything as expected.
Closing the plugin while a popup menu is open does not dismiss the menu (on OSX) and causes a crash in most DAWs on both OSs. This is a major bug that should be investigated by the JUCE team because it is crashing DAWs and there is seemingly no way to handle it. I’ve tried adding “PopupMenu::dismissAllActiveMenus()” in the destructors of classes that use the popup menu and that does not help. Please let me know if you have a solution to this!
Popup menus do not hide if I click somewhere off the menu that is not on the plugin or another app (ie: anywhere on the DAW itself). Since it does not hide it also means that it often gets in the way of other windows or tasks that a user may be using in the DAW. I already posted about this here: showMenuAsync() does not hide when clicked outside but received no response.
All this is to say that the behaviour of popup menus in plugins is not standard. Any reasonable user would expect that if they have a popup menu open, then clicking anywhere else on the screen will hide that popup menu. I’ve started looking into building my own popup menu dialog that takes the focus and is on top when opened, and (using focusLost()) will detect when focus is taken away and hides. However, I’m hesitant to commit to this direction because trying to build a popup menu that sizes correctly to fit in the bounds of the component and displays all submenus, icons, and other features that juce::PopupMenu has, and handles the result asynchronously sounds like such a nightmare… JUCE team, can you please take a look at fixing these issues so I don’t have to spend weeks essentially recreating your PopupMenu class to get one basic function that I need out of it… Many thanks!