Browse Source

PopupMenu: Use correct LookAndFeel when computing parent component

v7.0.9
reuk 2 years ago
parent
commit
e5fc50908e
No known key found for this signature in database GPG Key ID: FCB43929F012EE5C
1 changed files with 20 additions and 6 deletions
  1. +20
    -6
      modules/juce_gui_basics/menus/juce_PopupMenu.cpp

+ 20
- 6
modules/juce_gui_basics/menus/juce_PopupMenu.cpp View File

@@ -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;


Loading…
Cancel
Save