MenuΒΆ
Inherited: Frame
DescriptionΒΆ
The Menu class represents a graphical user interface (GUI) menu that contains a list of options or actions that users can select. It provides a way to organize and display commands or choices in a structured manner, typically within a dropdown or context menu format. Menus are essential in GUI design for providing users with accessible options and actions within an application.
Public MethodsΒΆ
void |
aboutToHide () |
void |
aboutToShow () |
void |
addAction (const TString & text, Sprite * icon = nullptr) |
void |
addSeparator () |
void |
addSubmenu (const TString & text, Menu * submenu, Sprite * icon = nullptr) |
Font * |
font () const |
void |
hide () |
Sprite * |
itemIcon (int index) |
itemText (int index) |
|
void |
setFont (Font * font) |
void |
setItemIcon (int index, Sprite * icon) |
void |
setItemText (int index, const TString & text) |
void |
show (const Vector2 & position) |
void |
triggered (int index) |
Static MethodsΒΆ
None
Methods DescriptionΒΆ
void Menu::aboutToHide ()
Signal emitted when the menu is about to be hidden.
void Menu::aboutToShow ()
Signal emitted when the menu is about to be shown.
Adds a section to the menu with the specified text and optional icon. Creates a clickable menu item that triggers an action when selected.
void Menu::addSeparator ()
Adds a separator line to the menu. Creates a visual separator to group related menu items.
Adds a submenu item with specified text and optional icon. Creates a menu item that opens a submenu when hovered or clicked.
Font * Menu::font () const
Returns the font which will be used to draw a text.
See also setFont().
void Menu::hide ()
Hides the menu.
Sprite * Menu::itemIcon (int index)
Returns the icon of the item at the specified index.
See also setItemIcon().
TString Menu::itemText (int index)
Returns the text of the item at the specified index.
See also setItemText().
void Menu::setFont (Font * font)
Changes the font which will be used to draw a text.
See also font().
void Menu::setItemIcon (int index, Sprite * icon)
Updates the icon of an existing menu item at index of menu position.
See also itemIcon().
void Menu::setItemText (int index, TString & text)
Updates the text of an existing menu item at index of menu position.
See also itemText().
void Menu::show (Vector2 & position)
Displays the menu at the specified position.
void Menu::triggered (int index)
Signal emitted when a menu with index item is triggered.