MenuItem

Menu item.

Header#include "nativeui/menu_item.h"
Namespacenamespace nu
Typeclass (RefCounted)

Constructors

Create a menu item.

Parameters

Methods

void Click()

Emulate user clicking the menu item.

void SetLabel(const std::string& label)

Change the item's label.

Parameters

std::string GetLabel() const

Return the item's label.

Return

std::string

void SetSubmenu(Menu* submenu)

Set the submenu attached to the item.

This method only works for submenu type menu items.

Parameters

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 IsChecked() const

Return the checked state of the item.

Return

bool

void SetEnabled(bool enabled)

Enable/disable the item.

Parameters

bool IsEnabled() const

Return whether the item is enabled.

Return

bool

void SetVisible(bool visible)

Show/hide the item.

Parameters

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

Accelerator GetAccelerator() const

Return the accelerator of the item.

Return

Accelerator

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

Preventable

No.