MenuItem
Menu item.
| Header | #include "nativeui/menu_item.h" | 
| Namespace | namespace nu | 
| Type | class (RefCounted) | 
Constructors
MenuItem(MenuItem::Type type)
Create a menu item.
Parameters
- MenuItem::Typetype
MenuItem(MenuItem::Role role)
Create a menu item with specified role.
Parameters
- MenuItem::Rolerole
Methods
void Click()
Emulate user clicking the menu item.
void SetLabel(const std::string& label)
Change the item's label.
Parameters
- const std::string&label
std::string GetLabel() const
Return the item's label.
Return
std::stringvoid SetSubmenu(scoped_refptr<Menu> submenu)
Set the submenu attached to the item.
This method only works for submenu type menu items.
Parameters
- scoped_refptr<Menu>submenu
Menu* GetSubmenu() const
Return the submenu attached to the item.
Return
Menu*void SetChecked(bool checked)
Set the checked state of the item.
This method only works for radio and checkbox type menu items.
Parameters
- boolchecked
bool IsChecked() const
Return the checked state of the item.
Return
boolvoid SetEnabled(bool enabled)
Enable/disable the item.
Parameters
- boolenabled
bool IsEnabled() const
Return whether the item is enabled.
Return
boolvoid SetVisible(bool visible)
Show/hide the item.
Parameters
- boolvisible
bool IsVisible() const
Return whether the item is visible to users.
Return
boolvoid SetAccelerator(const Accelerator& accelerator)
Set the accelerator used to activate the item.
Parameters
- const Accelerator&accelerator
Accelerator GetAccelerator() const
Return the accelerator of the item.
Return
Acceleratorvoid SetImage(scoped_refptr<Image> image) macOS Windows
Set the item's image.
Parameters
- scoped_refptr<Image>image
Image* GetImage() const macOS Windows
Return the item's image.
Return
Image*MenuItem::Type GetType() const
Return the type of the item.
Return
MenuItem::TypeMenuBase* GetMenu() const
Return the parent menu of the item.
Return
MenuBase*NativeMenuItem GetNative() const
Return the native instance wrapped by the item.
Return
NativeMenuItemEvents
void on_click(MenuItem* self)
Emitted when item is clicked.
Parameters
- MenuItem*self
Preventable
No.Delegates
bool validate(MenuItem* self)
Called before the item shows or activates, should return whether the item is enabled.
Parameters
- MenuItem*self
Return
bool