MenuItem
Menu item.
Module | require("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
Object
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