diff --git a/modules/juce_gui_basics/menus/juce_PopupMenu.cpp b/modules/juce_gui_basics/menus/juce_PopupMenu.cpp index e2a43d64e5..8dd135733a 100644 --- a/modules/juce_gui_basics/menus/juce_PopupMenu.cpp +++ b/modules/juce_gui_basics/menus/juce_PopupMenu.cpp @@ -324,12 +324,16 @@ private: //============================================================================== struct MenuWindow : public Component { - MenuWindow (const PopupMenu& menu, MenuWindow* parentWindow, - Options opts, bool alignToRectangle, bool shouldDismissOnMouseUp, - ApplicationCommandManager** manager, float parentScaleFactor = 1.0f) + MenuWindow (const PopupMenu& menu, + MenuWindow* parentWindow, + Options opts, + bool alignToRectangle, + bool shouldDismissOnMouseUp, + ApplicationCommandManager** manager, + float parentScaleFactor = 1.0f) : Component ("menu"), parent (parentWindow), - options (opts.withParentComponent (getLookAndFeel().getParentComponentForMenuOptions (opts))), + options (opts.withParentComponent (findLookAndFeel (menu, parentWindow)->getParentComponentForMenuOptions (opts))), managerOfChosenCommand (manager), componentAttachedTo (options.getTargetComponent()), dismissOnMouseUp (shouldDismissOnMouseUp), @@ -343,8 +347,7 @@ struct MenuWindow : public Component setAlwaysOnTop (true); setFocusContainerType (FocusContainerType::focusContainer); - setLookAndFeel (parent != nullptr ? &(parent->getLookAndFeel()) - : menu.lookAndFeel.get()); + setLookAndFeel (findLookAndFeel (menu, parentWindow)); auto& lf = getLookAndFeel(); @@ -1291,6 +1294,17 @@ struct MenuWindow : public Component })); } + LookAndFeel* findLookAndFeel (const PopupMenu& menu, MenuWindow* parentWindow) const + { + if (parentWindow != nullptr) + return &(parentWindow->getLookAndFeel()); + + if (auto* lnf = menu.lookAndFeel.get()) + return lnf; + + return &getLookAndFeel(); + } + //============================================================================== MenuWindow* parent; const Options options;