I'm working on an audio plugin project and want to use PopupMenu asynchronously.
Inside a mouseDown handler, I do the following:
if( isEnabled() && e.mods.isPopupMenu() ) { PopupMenu m; m.addItem ( 1, "A" ); m.addItem ( 2, "B" ); m.showAt( Rectangle<int>( e.getMouseDownScreenPosition(), e.getMouseDownScreenPosition() ), 0, 0, 0, 0, ModalCallbackFunction::forComponent<Component>( PluginEditor::contextMenuClicked, this ) ); }
The interface for the callback function asks for a static member, which works perfectly until one uses a second plugin instance. In my case, this callback function needs to *do something* with one specific PluginEditor instance (and not all of them). The only apparent work-around for me is to point to the latest instance statically (to access the instance and not just the class), but this only makes it worse. Oh well, and a synchronous PopupMenu isn't an option either afaik.
I do not understand why this function must be static and how to use it safely in an audio plug-in scenario (more accurately: In a dll). Does anyone know of a proven way to handle this case?