Blockly. MenuItem
Constructor
MenuItem
new MenuItem(content, opt_value)
Class representing an item in a menu.
Parameter |
|
---|---|
content |
(string or non-null HTMLElement) Text caption to display as the content of the item, or a HTML element to display. |
opt_value |
Optional string Data/model associated with the menu item. |
Property
content_
non-null HTMLElement
Methods
createDom
createDom() returns Element
Creates the menuitem's DOM.
- Returns
-
non-null Element
Completed DOM.
dispose
dispose()
Dispose of this menu item.
getElement
getElement() returns Element
Gets the menu item's element.
- Returns
-
Element
The DOM element.
getId
getId() returns string
Gets the unique ID for this menu item.
- Returns
-
string
Unique component ID.
getValue
getValue() returns any type
Gets the value associated with the menu item.
- Returns
-
any type
value Value associated with the menu item.
isEnabled
isEnabled() returns boolean
Returns true if the menu item is enabled, false otherwise.
- Returns
-
boolean
Whether the menu item is enabled.
onAction
onAction(fn, obj)
Set the handler that's called when the menu item is activated by the user.
obj
will be used as the 'this' object in the function when called.
Parameter |
|
---|---|
fn |
function(non-null Blockly.MenuItem) The handler. |
obj |
Object Used as the 'this' object in fn when called. Value must not be null. |
performAction
performAction()
Performs the appropriate action when the menu item is activated by the user.
setCheckable
setCheckable(checkable)
Sets the menu item to be checkable or not. Set to true for menu items that represent checkable options.
Parameter |
|
---|---|
checkable |
boolean Whether the menu item is checkable. |
setChecked
setChecked(checked)
Checks or unchecks the component.
Parameter |
|
---|---|
checked |
boolean Whether to check or uncheck the component. |
setEnabled
setEnabled(enabled)
Enables or disables the menu item.
Parameter |
|
---|---|
enabled |
boolean Whether to enable or disable the menu item. |
setHighlighted
setHighlighted(highlight)
Highlights or unhighlights the component.
Parameter |
|
---|---|
highlight |
boolean Whether to highlight or unhighlight the component. |
setRightToLeft
setRightToLeft(rtl)
Set menu item's rendering direction.
Parameter |
|
---|---|
rtl |
boolean True if RTL, false if LTR. |
setRole
setRole(roleName)
Set the menu item's accessibility role.
Parameter |
|
---|---|
roleName |
Role name. Value must not be null. |