Class MVToolButton
MVToolButton defines a clickable tool button displayed in a MVToolBar object. It response to mouse clicks by invoking the corresponding event handlers defined by the application. A tool button can be defined in one of the following three types:
- COMMAND: A command button has only one state, UP, and always reacts to mouse clicks by invoking the same BUTTON_DOWN event listener.
- TOGGLE: A toggle button has two states, DOWN and UP. The initial state of the button is UP. Its state changes to DOWN after it is clicked. It stays DOWN until it is clicked again, after which its state changes to UP. The BUTTON_DOWN event listener is invoked when the button state changes from UP to DOWN. The BUTTON_UP event listener is invoked when the button state changes from DOWN to UP.
- SEPERATOR: A seperator simply displays a static seperator icon that does not react to any user actions.
Constructor Attributes | Constructor Name and Description |
---|---|
MVToolButton(buttonID, buttonType, buttonIcon, buttonSelectedIcon)
|
Method Attributes | Method Name and Description |
---|---|
attachEventListener(event, listener)
This method attaches an event listener that handles one of the following tool button events:
MVEvent.BUTTON_DOWN and MVEvent.BUTTON_UP
|
|
detachEventListener(event, listener)
This method detaches an event listener that has previously been attached to the tool button
by #attachEventListener.
|
|
reset()
This method resets and releases the button if it is pressed down.
|
|
setToolTip(tooltip)
This method adds a tooltip to the button.
|
Class Detail
MVToolButton(buttonID, buttonType, buttonIcon, buttonSelectedIcon)
- Parameters:
- {String} buttonID
- A string that specifies the id of the button.
- {integer} buttonType
- ButtonType specifies the type of the new created button. It can be MVToolButton.COMMAND, MVToolButton.TOGGLE or MVToolButton.SEPARATOR. The default type is MVToolButton.COMMAND.
- {string} buttonIcon
- A string specifies a icon to be displayed when the button is in the UP state.
- {string} buttonSelectedIcon
- A string specifies a icon to be displayed when the button is in the DOWN state.
- Returns:
- The newly created MVToolButton object.
Method Detail
{void}
attachEventListener(event, listener)
This method attaches an event listener that handles one of the following tool button events:
MVEvent.BUTTON_DOWN and MVEvent.BUTTON_UP
- A MVEvent.BUTTON_DOWN event is fired when the user clicks a button and its state changes from UP to DOWN.
- A MVEvent.BUTTON_UP event is fired when the user clicks a button and its state changes from DOWN to UP.
- Parameters:
- {String} event
- a String that specifies the type of event to be handled by the listener. It can only be MVEvent.BUTTON_DOWN or MVEvent.BUTTON_UP.
- {Function} listener
- a javascript listener function. No parameter is passed to the listener when it is called.
- Returns:
- none
{void}
detachEventListener(event, listener)
This method detaches an event listener that has previously been attached to the tool button
by #attachEventListener.
- Parameters:
- {String} event
- a String that specifies the type of event handled by the listener. It can only be MVEvent.BUTTON_DOWN or MVEvent.BUTTON_UP.
- {Function} listener
- a javascript listener function. No parameter is passed to the listener when it is called.
- Returns:
- none
{void}
reset()
This method resets and releases the button if it is pressed down.
- Returns:
- None
{void}
setToolTip(tooltip)
This method adds a tooltip to the button. The tooltip is displayed when
the mouse moves over the button.
- Parameters:
- {string} tooltip
- a string that specifies the content of the tooltip.
- Returns:
- None