PopupMenu not showing on AUv3 plugin

OK. On the latest develop tip we’ve added support to “popup” a menu inside a parent component without the requirement of opening a separate window.

This can be done in two ways:

  1. via the the new withParentComponent PopupMenu::Options option. For example, creating a popup embedded in the top-level component could be done in the following way:

    menu.showMenuAsync (PopupMenu::Options().withParentComponent (target.getTopLevelComponent())
    .withTargetComponent (target), myCallback);

or
2) Override this option for all menus with a new LookAndFeel method:

  Component* getParentComponentForMenuOptions (const PopupMenu::Options& options);

For example, in an AUv3 plug-in this could be used in the following way:

class PopupMenuPluginAudioProcessorEditor  : public AudioProcessorEditor
{
public:
       PopupMenuPluginAudioProcessorEditor (AudioProcessor& processor)
            : AudioProcessorEditor (processor)
       {
           ....
           setLookAndFeel (&lf);
          setSize (300, 200);
       }
       .
       .
       .
private:
     class ForcePopupsInParentWindow : public LookAndFeel_V2
     {
     public:
         Component* getParentComponentForMenuOptions (const PopupMenu::Options& options) override
         {
        #if JUCE_IOS
            if (PluginHostType::getPluginLoadedAs() == AudioProcessor::wrapperType_AudioUnitv3)
            {
                 if (options.getParentComponent() == nullptr && options.getTargetComponent() != nullptr)
                     return options.getTargetComponent()->getTopLevelComponent();
            }
        #endif
        
           return LookAndFeel_V2::getParentComponentForMenuOptions (options);
         }
      };
 
     ForcePopupsInParentWindow lf;
};
6 Likes