Button Class

Custom button control. The button has 3 parts: icon, label, and an arrow.

Constructors

Button( parent, config )
Used to instantiate this class
parentDOM element in which to render this component
configConfiguration settings (optional). See config options for more information.

Config Options

label
Text label for the button.
selected
If true, the button will initially appear in a selected state and the isSelected() method will return true. Default is false.
disabled
If true, the button will initially appear disabled and the isDisabled() method will return true. Default is false.
toggle
If true, the button will be rendered as a toggle button. Default is false, unless the button has a menu.
menu
If true, will create a drop-down menu for the button. Components such as buttons or custom DOM elements can be added directly to the menu. See getMenuPanel() for more information.
menuAlign
Sets the position of the menu panel. Options are "bottom" or "right".
display
Used to set the "display" style attribute for the outer DOM element. This is not commonly ued. Default is "inline-block".
width
Used to set the width of the button. This property is optional.
height
Used to set the height of the button. This property is optional.
iconAlign
Used to set the icon position relative to the button label. Options are "left" or "right". Note that the icon style is set in the style config. The icon style should not be used to control whether the icon appears to the left or right of the label. Use this config instead.
style
Style for individual elements within the component. Note that you can provide CSS class names instead of individual style definitions.
sound
Sound to play when the button is clicked

Events

onClick( )
Called whenever the button is clicked.

Public Methods

click( )
Used to click the button and fire onClick event
getText( )
Returns the button label. Same as getLabel().
getLabel( )
Returns the button label.
setLabel( str )
Used to update the button label.
enable( )
Used to enable the button.
disable( )
Used to disable the button.
isEnabled( )
Returns true if the button is enabled (i.e. not disabled).
isDisabled( )
Returns true if the button is disabled.
select( )
Used to update the "selected" state of the button.
deselect( )
Used to update the "selected" state of the button.
isSelected( )
Returns true if the button is selected (e.g. depressed)
toggle( )
Used to toggle the button's selection state.
getMenuPanel( )
Returns the DOM element associated with the menu panel. Typically, this is used to render menu options (i.e. buttons).