Class GSMenuItem
A UI control providing a single menu item in a menu.
| Constructor Attributes | Constructor Name and Description |
|---|---|
|
GSMenuItem(options)
|
| Method Attributes | Method Name and Description |
|---|---|
|
addEventHandler(eventType, func)
Adds an event handler function to this menu item
Any DOM Level 2 mouse event type may be specified for the
eventType
argument:
|
|
|
addEventListener(eventType, func, scope)
Registers the given function as a handler for DOM events of the specified
type occurring on the component's target element.
|
|
|
Gets this menu item's height
|
|
|
Gets this menu item's padding
|
|
|
getWidth()
Gets this menu item's width
|
|
|
Returns
true if this menu item should be able to receive focus |
|
|
remove()
Removes this menu item from it's parent menu
|
|
|
removeEventHandler(token)
Removes the event handler function represented by the
token parameter
from this menu item |
|
|
removeEventListener(token)
Removes the event listener function represented by the
token parameter
from this feature |
|
|
Removes all registered event listeners from the component's target element
|
|
|
setEnabled(enabled)
Sets the
enabled property of the menu item |
|
|
setLabel(label)
Sets the menu items label
|
|
|
setStyles(an)
Sets the specified styles for this button
|
Class Detail
GSMenuItem(options)
- Parameters:
- {Object} options Optional
- an object literal specifying the menu item options to set:
- {boolean} options.enabled
- when
truethe menu item is enabled and will respond to user events. Defaults totrue - {String} options.type
- the type of the menu item. Valid values are
separatorandcheck. If not specified a normal menu item will be created. - {int} options.width
- the width of this menu item
- {int} options.width
- the height of this menu item
- {String} options.padding
- the menu item's padding
- {String} options.icon
- the URL of an icon to use with the label text. Icons are rendered to the left of the label text.
- {Function} options.action
- a function to be invoked when this menu item is clicked. If this menu item is not enabled the action will not be executed
Method Detail
{Object}
addEventHandler(eventType, func)
Adds an event handler function to this menu item
Any DOM Level 2 mouse event type may be specified for the
eventType
argument:
- click - the click event occurs when the mouse button is clicked over the feature.
- mousedown - the mousedown event occurs when the mouse button is pressed over the feature
- mouseup - the mouseup event occurs when the mouse button is released over the feature
- mouseover - the mouseover event occurs when the mouse is moved onto the feature
- mousemove - the mousemove event occurs when the mouse is moved while it is over the feature
- mouseout - the mouseout event occurs when the mouse is moved away from the feature
- Parameters:
- {String} eventType
- the event that should trigger the handler function
- {Function} func
- the function to be invoked when the event is triggered
- Deprecated:
- use GSMenuItem#addEventListener instead
- Returns:
- {Object} a token that can be passed to the
GSMenuItem.removeEventHandler()method to remove the event handler
{Object}
addEventListener(eventType, func, scope)
Registers the given function as a handler for DOM events of the specified
type occurring on the component's target element. This function returns a token
that can be passed to the #removeEventListener to remove the event
listener. If the
scope argument is not passed the function will execute in the context
of this object
- Parameters:
- {String} eventType
- the event type to add the listener for. Can be one of:
click, mousedown, mouseup, mouseover, mouseout - {Function} func
- The function to invoke when the event is triggered
- {Object} scope Optional
- the scope (
thisreference) in which the function is executed
- Throws:
- {Error}
- if this component does not define a reference to its DOM element
- Returns:
- {Object} a token that can be passed to the GSEventManager#removeEventListener to remove the event listener.
{int}
getHeight()
Gets this menu item's height
- Returns:
- {int} the width of this menu item
{String}
getPadding()
Gets this menu item's padding
- Returns:
- {String} the menu item's padding
{int}
getWidth()
Gets this menu item's width
- Returns:
- {int} the width of this menu item
{boolean}
isFocusTraversable()
Returns
true if this menu item should be able to receive focus
- Returns:
- {boolean}
trueif the menu item is able to receive focus
remove()
Removes this menu item from it's parent menu
removeEventHandler(token)
Removes the event handler function represented by the
token parameter
from this menu item
- Parameters:
- {Object} token
- a token identifying the event handler to be removed
- Deprecated:
- use GSMenuItem#removeEventListener instead
removeEventListener(token)
Removes the event listener function represented by the
token parameter
from this feature
- Parameters:
- {Object} token
- a token identifying the event handler to be removed
removeEventListeners()
Removes all registered event listeners from the component's target element
setEnabled(enabled)
Sets the
enabled property of the menu item
- Parameters:
- {boolean} enabled
trueif the menu item should be enabled
setLabel(label)
Sets the menu items label
- Parameters:
- {String} label
- the label to set
setStyles(an)
Sets the specified styles for this button
- Parameters:
- {Object} an
- object literal specifying the styles to set