If you’re looking for workarounds, one possiblity might be to override getParentComponentForMenuOptions
to return a pointer to your top-level component in your look and feel.
Taking the LookAndFeel example above, adjust it like so:
class TestLookAndFeel : public LookAndFeel_V4
{
public:
explicit TestLookAndFeel (juce::Component& tlc)
: topLevelComponent (tlc)
{
const Colour newBgColour (53, 53, 53);
const Colour newFgColour (220, 220, 220);
setColour (PopupMenu::highlightedBackgroundColourId, newFgColour);
setColour (PopupMenu::highlightedTextColourId, newBgColour.withAlpha (0.9f));
setColour (PopupMenu::backgroundColourId, newBgColour.withAlpha (0.9f));
setColour (PopupMenu::textColourId, newFgColour);
}
juce::Component* getParentComponentForMenuOptions (const PopupMenu::Options&) override
{
return &topLevelComponent;
}
void drawPopupMenuBackground (Graphics& g, int width, int height) override
{
Rectangle<int> area (0, 0, width, height);
g.setColour (findColour (PopupMenu::backgroundColourId));
g.fillRoundedRectangle (area.toFloat().reduced (0.5f), 4.0f);
}
juce::Component& topLevelComponent;
};
When constructing the LookAndFeel, pass in a reference to your plugin’s AudioProcessorEditor
.
Now, the popupmenu will be added to your main editor window, rather than creating a whole new floating window. It should render correctly, although the size of the popup menu will be constrained to the size of the main editor window.