MenuItem
Menu item.
Module | require("yue.gui") |
Type | Class |
Class methods
create(type)
Create a menu item with type
.
Parameters
MenuItem::Type
type
Return
MenuItem
create(options)
Create a menu item with options
.
Parameters
table
optionsMenuItem::Type
typeMenuItem::Role
roleboolean
checkedMenu
submenuboolean
visibleboolean
enabledstring
labelAccelerator
acceleratorImage
imagefunction
onclick
Return
MenuItem
Methods
click()
Emulate user clicking the menu item.
setlabel(label)
Change the item's label.
Parameters
string
label
getlabel()
Return the item's label.
Return
string
setsubmenu(submenu)
Set the submenu attached to the item.
This method only works for submenu
type menu items.
Parameters
Menu
submenu
getsubmenu()
Return the submenu attached to the item.
Return
Menu
setchecked(checked)
Set the checked
state of the item.
This method only works for radio
and checkbox
type menu items.
Parameters
boolean
checked
ischecked()
Return the checked
state of the item.
Return
boolean
setenabled(enabled)
Enable/disable the item.
Parameters
boolean
enabled
isenabled()
Return whether the item is enabled.
Return
boolean
setvisible(visible)
Show/hide the item.
Parameters
boolean
visible
isvisible()
Return whether the item is visible to users.
Return
boolean
setaccelerator(accelerator)
Set the accelerator
used to activate the item.
Parameters
Accelerator
accelerator
macOS Windows
setimage(image)Set the item's image.
Parameters
Image
image
macOS Windows
getimage()Return the item's image.
Return
Image
Events
onclick(self)
Emitted when item is clicked.
Parameters
MenuItem
self
Preventable
No.Delegates
validate(self)
Called before the item shows or activates, should return whether the item is enabled.
Parameters
MenuItem
self
Return
boolean