Loading...
Searching...
No Matches
juce::PopupMenu::Item Struct Reference

## Detailed Description

Describes a popup menu item.

The documentation for this struct was generated from the following file:

- juce_gui_basics/menus/juce_PopupMenu.h

## Public Member Functions

| Item ()
| Creates a null item.
| Item (String text)
| Creates an item with the given text.
| Item (const Item &)
Item & | operator= (const Item &)
| Item (Item &&)
Item & | operator= (Item &&)
Item & | setTicked (bool shouldBeTicked=true) &noexcept
| Sets the isTicked flag (and returns a reference to this item to allow chaining).
Item & | setEnabled (bool shouldBeEnabled) &noexcept
| Sets the isEnabled flag (and returns a reference to this item to allow chaining).
Item & | setAction (std::function< void()> action) &noexcept
| Sets the action property (and returns a reference to this item to allow chaining).
Item & | setID (int newID) &noexcept
| Sets the itemID property (and returns a reference to this item to allow chaining).
Item & | setColour (Colour) &noexcept
| Sets the colour property (and returns a reference to this item to allow chaining).
Item & | setCustomComponent (ReferenceCountedObjectPtr< CustomComponent > customComponent) &noexcept
| Sets the customComponent property (and returns a reference to this item to allow chaining).
Item & | setImage (std::unique_ptr< Drawable >) &noexcept
| Sets the image property (and returns a reference to this item to allow chaining).
Item && | setTicked (bool shouldBeTicked=true) &&noexcept
| Sets the isTicked flag (and returns a reference to this item to allow chaining).
Item && | setEnabled (bool shouldBeEnabled) &&noexcept
| Sets the isEnabled flag (and returns a reference to this item to allow chaining).
Item && | setAction (std::function< void()> action) &&noexcept
| Sets the action property (and returns a reference to this item to allow chaining).
Item && | setID (int newID) &&noexcept
| Sets the itemID property (and returns a reference to this item to allow chaining).
Item && | setColour (Colour) &&noexcept
| Sets the colour property (and returns a reference to this item to allow chaining).
Item && | setCustomComponent (ReferenceCountedObjectPtr< CustomComponent > customComponent) &&noexcept
| Sets the customComponent property (and returns a reference to this item to allow chaining).
Item && | setImage (std::unique_ptr< Drawable >) &&noexcept
| Sets the image property (and returns a reference to this item to allow chaining).

## Public Attributes

String | text
| The menu item's name.
int | itemID = 0
| The menu item's ID.
std::function< void()> | action
| An optional function which should be invoked when this menu item is triggered.
std::unique_ptr< PopupMenu > | subMenu
| A sub-menu, or nullptr if there isn't one.
std::unique_ptr< Drawable > | image
| A drawable to use as an icon, or nullptr if there isn't one.
ReferenceCountedObjectPtr< CustomComponent > | customComponent
| A custom component for the item to display, or nullptr if there isn't one.
ReferenceCountedObjectPtr< CustomCallback > | customCallback
| A custom callback for the item to use, or nullptr if there isn't one.
ApplicationCommandManager * | commandManager = nullptr
| A command manager to use to automatically invoke the command, or nullptr if none is specified.
String | shortcutKeyDescription
| An optional string describing the shortcut key for this item.
Colour | colour
| A colour to use to draw the menu text.
bool | isEnabled = true
| True if this menu item is enabled.
bool | isTicked = false
| True if this menu item should have a tick mark next to it.
bool | isSeparator = false
| True if this menu item is a separator line.
bool | isSectionHeader = false
| True if this menu item is a section header.
bool | shouldBreakAfter = false
| True if this is the final item in the current column.

## Constructors and Destructors

## Item() [1/4]

juce::PopupMenu::Item::Item | ( |  | ) |

Creates a null item.

You'll need to set some fields after creating an Item before you can add it to a PopupMenu

Referenced by Item(), Item(), operator=(), operator=(), setAction(), setAction(), setColour(), setColour(), setCustomComponent(), setCustomComponent(), setEnabled(), setEnabled(), setID(), setID(), setImage(), setImage(), setTicked(), and setTicked().

## Item() [2/4]

juce::PopupMenu::Item::Item | ( | String | text | ) |

Creates an item with the given text.

This constructor also initialises the itemID to -1, which makes it suitable for creating lambda-based item actions.

References text.

## Item() [3/4]

juce::PopupMenu::Item::Item | ( | const Item & |  | ) |

References Item().

## Item() [4/4]

juce::PopupMenu::Item::Item | ( | Item && |  | ) |

References Item().

## Member Functions

## operator=() [1/2]

Item & juce::PopupMenu::Item::operator= | ( | const Item & |  | ) |

References Item().

## operator=() [2/2]

Item & juce::PopupMenu::Item::operator= | ( | Item && |  | ) |

References Item().

## setTicked() [1/2]

Item & juce::PopupMenu::Item::setTicked | ( | bool | shouldBeTicked = true | ) | &

noexcept

Sets the isTicked flag (and returns a reference to this item to allow chaining).

References Item().

## setEnabled() [1/2]

Item & juce::PopupMenu::Item::setEnabled | ( | bool | shouldBeEnabled | ) | &

noexcept

Sets the isEnabled flag (and returns a reference to this item to allow chaining).

References Item().

## setAction() [1/2]

Item & juce::PopupMenu::Item::setAction | ( | std::function< void()> | action | ) | &

noexcept

Sets the action property (and returns a reference to this item to allow chaining).

References action, and Item().

## setID() [1/2]

Item & juce::PopupMenu::Item::setID | ( | int | newID | ) | &

noexcept

Sets the itemID property (and returns a reference to this item to allow chaining).

References Item().

## setColour() [1/2]

Item & juce::PopupMenu::Item::setColour | ( | Colour |  | ) | &

noexcept

Sets the colour property (and returns a reference to this item to allow chaining).

References Item().

## setCustomComponent() [1/2]

Item & juce::PopupMenu::Item::setCustomComponent | ( | ReferenceCountedObjectPtr< CustomComponent > | customComponent | ) | &

noexcept

Sets the customComponent property (and returns a reference to this item to allow chaining).

References customComponent, and Item().

## setImage() [1/2]

Item & juce::PopupMenu::Item::setImage | ( | std::unique_ptr< Drawable > |  | ) | &

noexcept

Sets the image property (and returns a reference to this item to allow chaining).

References Item().

## setTicked() [2/2]

Item && juce::PopupMenu::Item::setTicked | ( | bool | shouldBeTicked = true | ) | &&

noexcept

Sets the isTicked flag (and returns a reference to this item to allow chaining).

References Item().

## setEnabled() [2/2]

Item && juce::PopupMenu::Item::setEnabled | ( | bool | shouldBeEnabled | ) | &&

noexcept

Sets the isEnabled flag (and returns a reference to this item to allow chaining).

References Item().

## setAction() [2/2]

Item && juce::PopupMenu::Item::setAction | ( | std::function< void()> | action | ) | &&

noexcept

Sets the action property (and returns a reference to this item to allow chaining).

References action, and Item().

## setID() [2/2]

Item && juce::PopupMenu::Item::setID | ( | int | newID | ) | &&

noexcept

Sets the itemID property (and returns a reference to this item to allow chaining).

References Item().

## setColour() [2/2]

Item && juce::PopupMenu::Item::setColour | ( | Colour |  | ) | &&

noexcept

Sets the colour property (and returns a reference to this item to allow chaining).

References Item().

## setCustomComponent() [2/2]

Item && juce::PopupMenu::Item::setCustomComponent | ( | ReferenceCountedObjectPtr< CustomComponent > | customComponent | ) | &&

noexcept

Sets the customComponent property (and returns a reference to this item to allow chaining).

References customComponent, and Item().

## setImage() [2/2]

Item && juce::PopupMenu::Item::setImage | ( | std::unique_ptr< Drawable > |  | ) | &&

noexcept

Sets the image property (and returns a reference to this item to allow chaining).

References Item().

## Member Data Documentation

## text

String juce::PopupMenu::Item::text

The menu item's name.

Referenced by Item().

## itemID

int juce::PopupMenu::Item::itemID = 0

The menu item's ID.

This must not be 0 if you want the item to be triggerable, but if you're attaching an action callback to the item, you can set the itemID to -1 to indicate that it isn't actively needed.

## action

std::function<void()> juce::PopupMenu::Item::action

An optional function which should be invoked when this menu item is triggered.

Referenced by setAction(), and setAction().

## subMenu

std::unique_ptr<PopupMenu> juce::PopupMenu::Item::subMenu

A sub-menu, or nullptr if there isn't one.

## image

std::unique_ptr<Drawable> juce::PopupMenu::Item::image

A drawable to use as an icon, or nullptr if there isn't one.

## customComponent

ReferenceCountedObjectPtr<CustomComponent> juce::PopupMenu::Item::customComponent

A custom component for the item to display, or nullptr if there isn't one.

Referenced by setCustomComponent(), and setCustomComponent().

## customCallback

ReferenceCountedObjectPtr<CustomCallback> juce::PopupMenu::Item::customCallback

A custom callback for the item to use, or nullptr if there isn't one.

## commandManager

ApplicationCommandManager* juce::PopupMenu::Item::commandManager = nullptr

A command manager to use to automatically invoke the command, or nullptr if none is specified.

## shortcutKeyDescription

String juce::PopupMenu::Item::shortcutKeyDescription

An optional string describing the shortcut key for this item.

This is only used for displaying at the right-hand edge of a menu item - the menu won't attempt to actually catch or process the key. If you supply a commandManager parameter then the menu will attempt to fill-in this field automatically.

## colour

Colour juce::PopupMenu::Item::colour

A colour to use to draw the menu text.

By default this is transparent black, which means that the LookAndFeel should choose the colour.

## isEnabled

bool juce::PopupMenu::Item::isEnabled = true

True if this menu item is enabled.

## isTicked

bool juce::PopupMenu::Item::isTicked = false

True if this menu item should have a tick mark next to it.

## isSeparator

bool juce::PopupMenu::Item::isSeparator = false

True if this menu item is a separator line.

## isSectionHeader

bool juce::PopupMenu::Item::isSectionHeader = false

True if this menu item is a section header.

## shouldBreakAfter

bool juce::PopupMenu::Item::shouldBreakAfter = false

True if this is the final item in the current column.

### Purchase

Get JUCE

### Discover

What's New in JUCE Features

### Learn

Documentaion Tutorials Made with JUCE Resources

### Support

JUCE Forum Newsletter Archive

### About

Contact Us JUCE Legal JUCE Licensing FAQ

### Events

Audio Developer Conference
© Raw Material Software Limited