MenuItem
Menu item.
| Module | require("yue.gui") |
| Type | Class |
Class methods
create(type)
Create a menu item with type.
Parameters
MenuItem::Typetype
Return
MenuItemcreate(options)
Create a menu item with options.
Parameters
tableoptionsMenuItem::TypetypeMenuItem::RolerolebooleancheckedMenusubmenubooleanvisiblebooleanenabledstringlabelAcceleratoracceleratorImageimagefunctiononclick
Return
MenuItemMethods
click()
Emulate user clicking the menu item.
setlabel(label)
Change the item's label.
Parameters
stringlabel
getlabel()
Return the item's label.
Return
stringsetsubmenu(submenu)
Set the submenu attached to the item.
This method only works for submenu type menu items.
Parameters
Menusubmenu
getsubmenu()
Return the submenu attached to the item.
Return
Menusetchecked(checked)
Set the checked state of the item.
This method only works for radio and checkbox type menu items.
Parameters
booleanchecked
ischecked()
Return the checked state of the item.
Return
booleansetenabled(enabled)
Enable/disable the item.
Parameters
booleanenabled
isenabled()
Return whether the item is enabled.
Return
booleansetvisible(visible)
Show/hide the item.
Parameters
booleanvisible
isvisible()
Return whether the item is visible to users.
Return
booleansetaccelerator(accelerator)
Set the accelerator used to activate the item.
Parameters
Acceleratoraccelerator
setimage(image) macOS Windows
Set the item's image.
Parameters
Imageimage
getimage() macOS Windows
Return the item's image.
Return
ImageEvents
onclick(self)
Emitted when item is clicked.
Parameters
MenuItemself
Preventable
No.Delegates
validate(self)
Called before the item shows or activates, should return whether the item is enabled.
Parameters
MenuItemself
Return
boolean