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::Type
type
MenuItem(MenuItem::Role role)
Create a menu item with specified role
.
Parameters
MenuItem::Role
role
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::string
void 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
bool
checked
bool IsChecked() const
Return the checked
state of the item.
Return
bool
void SetEnabled(bool enabled)
Enable/disable the item.
Parameters
bool
enabled
bool IsEnabled() const
Return whether the item is enabled.
Return
bool
void SetVisible(bool visible)
Show/hide the item.
Parameters
bool
visible
bool IsVisible() const
Return whether the item is visible to users.
Return
bool
void 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
Accelerator
macOS Windows
void SetImage(scoped_refptr<Image> image)Set the item's image.
Parameters
scoped_refptr<Image>
image
macOS Windows
Image* GetImage() constReturn the item's image.
Return
Image*
MenuItem::Type GetType() const
Return the type of the item.
Return
MenuItem::Type
MenuBase* GetMenu() const
Return the parent menu of the item.
Return
MenuBase*
NativeMenuItem GetNative() const
Return the native instance wrapped by the item.
Return
NativeMenuItem
Events
void on_click(MenuItem* self)
Emitted when item is clicked.
Parameters
MenuItem*
self