1
0
Fork 0
mirror of https://github.com/juce-framework/JUCE.git synced 2026-01-10 23:44:24 +00:00

PopupMenu: Add Item tooltipText

This commit is contained in:
zsliu98 2025-03-07 00:01:20 -05:00
parent 4deee6976b
commit 7455c19a43
No known key found for this signature in database
GPG key ID: FE35AB56C95B3202
2 changed files with 6 additions and 1 deletions

View file

@ -120,11 +120,13 @@ struct HeaderItemComponent final : public PopupMenu::CustomComponent
};
//==============================================================================
struct ItemComponent final : public Component
struct ItemComponent final : public Component, public SettableTooltipClient
{
ItemComponent (const PopupMenu::Item& i, const PopupMenu::Options& o, MenuWindow& parent)
: item (i), parentWindow (parent), options (o), customComp (i.customComponent)
{
SettableTooltipClient::setTooltip(item.tooltipText);
if (item.isSectionHeader)
customComp = *new HeaderItemComponent (item.text, options);
@ -1708,6 +1710,7 @@ PopupMenu::Item& PopupMenu::Item::operator= (Item&&) = default;
PopupMenu::Item::Item (const Item& other)
: text (other.text),
tooltipText(other.tooltipText),
itemID (other.itemID),
action (other.action),
subMenu (createCopyIfNotNull (other.subMenu.get())),
@ -1727,6 +1730,7 @@ PopupMenu::Item::Item (const Item& other)
PopupMenu::Item& PopupMenu::Item::operator= (const Item& other)
{
text = other.text;
tooltipText = other.tooltipText;
itemID = other.itemID;
action = other.action;
subMenu.reset (createCopyIfNotNull (other.subMenu.get()));

View file

@ -137,6 +137,7 @@ public:
/** The menu item's name. */
String text;
String tooltipText = "";
/** The menu item's ID.
This must not be 0 if you want the item to be triggerable, but if you're attaching