Skip to content

Commit 7455c19

Browse files
committed
PopupMenu: Add Item tooltipText
1 parent 4deee69 commit 7455c19

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

modules/juce_gui_basics/menus/juce_PopupMenu.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,11 +120,13 @@ struct HeaderItemComponent final : public PopupMenu::CustomComponent
120120
};
121121

122122
//==============================================================================
123-
struct ItemComponent final : public Component
123+
struct ItemComponent final : public Component, public SettableTooltipClient
124124
{
125125
ItemComponent (const PopupMenu::Item& i, const PopupMenu::Options& o, MenuWindow& parent)
126126
: item (i), parentWindow (parent), options (o), customComp (i.customComponent)
127127
{
128+
SettableTooltipClient::setTooltip(item.tooltipText);
129+
128130
if (item.isSectionHeader)
129131
customComp = *new HeaderItemComponent (item.text, options);
130132

@@ -1708,6 +1710,7 @@ PopupMenu::Item& PopupMenu::Item::operator= (Item&&) = default;
17081710

17091711
PopupMenu::Item::Item (const Item& other)
17101712
: text (other.text),
1713+
tooltipText(other.tooltipText),
17111714
itemID (other.itemID),
17121715
action (other.action),
17131716
subMenu (createCopyIfNotNull (other.subMenu.get())),
@@ -1727,6 +1730,7 @@ PopupMenu::Item::Item (const Item& other)
17271730
PopupMenu::Item& PopupMenu::Item::operator= (const Item& other)
17281731
{
17291732
text = other.text;
1733+
tooltipText = other.tooltipText;
17301734
itemID = other.itemID;
17311735
action = other.action;
17321736
subMenu.reset (createCopyIfNotNull (other.subMenu.get()));

modules/juce_gui_basics/menus/juce_PopupMenu.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,7 @@ class JUCE_API PopupMenu
137137

138138
/** The menu item's name. */
139139
String text;
140+
String tooltipText = "";
140141

141142
/** The menu item's ID.
142143
This must not be 0 if you want the item to be triggerable, but if you're attaching

0 commit comments

Comments
 (0)