Class: MenuItem

Constructor

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

package

getElement() returns Element

Gets the menu item's element.

Returns

Element The DOM element.

getId

package

getId() returns string

Gets the unique ID for this menu item.

Returns

string Unique component ID.

getValue

package

getValue() returns any type

Gets the value associated with the menu item.

Returns

any type value Value associated with the menu item.

isEnabled

package

isEnabled() returns boolean

Returns true if the menu item is enabled, false otherwise.

Returns

boolean Whether the menu item is enabled.

onAction

package

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

package

performAction()

Performs the appropriate action when the menu item is activated by the user.

setCheckable

package

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

package

setChecked(checked)

Checks or unchecks the component.

Parameter

checked

boolean

Whether to check or uncheck the component.

setEnabled

package

setEnabled(enabled)

Enables or disables the menu item.

Parameter

enabled

boolean

Whether to enable or disable the menu item.

setHighlighted

package

setHighlighted(highlight)

Highlights or unhighlights the component.

Parameter

highlight

boolean

Whether to highlight or unhighlight the component.

setRightToLeft

package

setRightToLeft(rtl)

Set menu item's rendering direction.

Parameter

rtl

boolean

True if RTL, false if LTR.

setRole

package

setRole(roleName)

Set the menu item's accessibility role.

Parameter

roleName

Blockly.utils.aria.Role

Role name.

Value must not be null.