interface org.aswing.ButtonModel

State Model for buttons. This model is used for check boxes and radio buttons, which are special kinds of buttons, as well as for normal buttons. For check boxes and radio buttons, pressing the mouse selects the button. For normal buttons, pressing the mouse "arms" the button. Releasing the mouse over the button then initiates a button press, firing its action event. Releasing the mouse elsewhere disarms the button.

In use, a UI will invoke setSelected when a mouse click occurs over a check box or radio button. It will invoke setArmed</code when the mouse is pressed over a regular button and invoke setPressed</code when the mouse is released. If the mouse travels outside the button in the meantime, setArmed(false) will tell the button not to fire when it sees setPressed. (If the mouse travels back in, the button will be rearmed.)

Note:
A button is triggered when it is both "armed" and "pressed".

Buttons always fire programmatic=false InteractiveEvent.

@author paling

Instance Fields

function addActionListener(listener:Dynamic ->Void?priority:Int, ?useWeakReference:Bool): Void

Adds a listener to listen the Model's act event. When the button model's armed and pressed to fire this event. @see org.aswing.event.AWEvent#ACT

listener

the listener

priority

the priority

useWeakReference

Determines whether the reference to the listener is strong or weak.

function addSelectionListener(listener:Dynamic ->Void?priority:Int, ?useWeakReference:Bool): Void

Add a listener to listen the Model's selection change event. When the button's selection changed, fired when diselected or selected. @see org.aswing.event.InteractiveEvent#SELECTION_CHANGED

listener

the listener

priority

the priority

useWeakReference

Determines whether the reference to the listener is strong or weak.

function addStateListener(listener:Dynamic ->Void?priority:Int, ?useWeakReference:Bool): Void

Adds a listener to listen the Model's state change event.

When the button's state changed, the state is all about:

  • enabled
  • rollOver
  • pressed
  • released
  • selected

Buttons always fire programmatic=false InteractiveEvent.

@see org.aswing.event.InteractiveEvent#STATE_CHANGED

listener

the listener

priority

the priority

useWeakReference

Determines whether the reference to the listener is strong or weak.

function isArmed(): Bool

Indicates partial commitment towards pressing the button.

Note, this is similar to AS2 version's both pressed and rollover.

returns

true if the button is armed, and ready to be pressed

function isEnabled(): Bool

Indicates if the button can be selected or pressed by an input device (such as a mouse pointer).

returns

true if the button is enabled, and therefore selectable (or pressable)

function isPressed(): Bool

Indicates if button has been pressed.

returns

true if the button has been pressed

function isRollOver(): Bool

Indicates that the mouse is over the button.

returns

true if the mouse is over the button

function isSelected(): Bool

Indicates if the button has been selected.

function removeActionListener(listener:Dynamic ->Void): Void

Removes a action listener. @see org.aswing.event.AWEvent#ACT

listener

the listener to be removed.

function removeSelectionListener(listener:Dynamic ->Void): Void

Removes a selection listener. @see org.aswing.event.InteractiveEvent#SELECTION_CHANGED

listener

the listener to be removed.

function removeStateListener(listener:Dynamic ->Void): Void

Removes a state listener. @see org.aswing.event.InteractiveEvent#STATE_CHANGED

listener

the listener to be removed.

function setArmed(b:Bool): Void

Marks the button as "armed". If the mouse button is released while it is over this item, the button's action event fires. If the mouse button is released elsewhere, the event does not fire and the button is disarmed.

b

true to arm the button so it can be selected

function setEnabled(b:Bool): Void

Enables or disables the button.

function setGroup(group:ButtonGroup): Void

Identifies the group this button belongs to -- needed for radio buttons, which are mutually exclusive within their group.

group

the ButtonGroup this button belongs to

function setPressed(b:Bool): Void

Sets the button to being pressed or unpressed.

function setRollOver(b:Bool): Void

Sets or clears the button's rollover state

@see #isRollover

b

true to turn on rollover

function setSelected(b:Bool): Void

Selects or deselects the button.

b

true selects the button, false deselects the button.