Browse Source

PopupMenu: added option to include an iconToUse to addCommandItem.

tags/2021-05-28
Timur Doumler 10 years ago
parent
commit
db078f194d
2 changed files with 9 additions and 3 deletions
  1. +3
    -2
      modules/juce_gui_basics/menus/juce_PopupMenu.cpp
  2. +6
    -1
      modules/juce_gui_basics/menus/juce_PopupMenu.h

+ 3
- 2
modules/juce_gui_basics/menus/juce_PopupMenu.cpp View File

@@ -1328,7 +1328,8 @@ void PopupMenu::addItem (int itemResultID, const String& itemText, bool isActive
void PopupMenu::addCommandItem (ApplicationCommandManager* commandManager,
const CommandID commandID,
const String& displayName)
const String& displayName,
Drawable* iconToUse)
{
jassert (commandManager != nullptr && commandID != 0);
@@ -1342,7 +1343,7 @@ void PopupMenu::addCommandItem (ApplicationCommandManager* commandManager,
: info.shortName,
target != nullptr && (info.flags & ApplicationCommandInfo::isDisabled) == 0,
(info.flags & ApplicationCommandInfo::isTicked) != 0,
nullptr,
iconToUse,
Colours::black,
false,
nullptr, nullptr,


+ 6
- 1
modules/juce_gui_basics/menus/juce_PopupMenu.h View File

@@ -165,10 +165,15 @@ public:
@param commandID the ID of the command
@param displayName if this is non-empty, then this string will be used instead of
the command's registered name
@param iconToUse an optional Drawable object to use as the icon to the left of the item.
The menu will take ownership of this drawable object and will
delete it later when no longer needed
*/
void addCommandItem (ApplicationCommandManager* commandManager,
CommandID commandID,
const String& displayName = String::empty);
const String& displayName = String::empty,
Drawable* iconToUse = nullptr);
/** Appends a text item with a special colour.


Loading…
Cancel
Save