Packageorg.aswing
Interfacepublic interface ButtonModel
ImplementorsDefaultButtonModel

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 setArmedsetPressedsetArmed(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.



Public Methods
 MethodDefined by
  
addActionListener(listener:Function, priority:int = 0, useWeakReference:Boolean = false):void
Adds a listener to listen the Model's act event.
ButtonModel
  
addSelectionListener(listener:Function, priority:int = 0, useWeakReference:Boolean = false):void
Add a listener to listen the Model's selection change event.
ButtonModel
  
addStateListener(listener:Function, priority:int = 0, useWeakReference:Boolean = false):void
Adds a listener to listen the Model's state change event.
ButtonModel
  
isArmed():Boolean
Indicates partial commitment towards pressing the button.
ButtonModel
  
isEnabled():Boolean
Indicates if the button can be selected or pressed by an input device (such as a mouse pointer).
ButtonModel
  
isPressed():Boolean
Indicates if button has been pressed.
ButtonModel
  
isRollOver():Boolean
Indicates that the mouse is over the button.
ButtonModel
  
isSelected():Boolean
Indicates if the button has been selected.
ButtonModel
  
removeActionListener(listener:Function):void
Removes a action listener.
ButtonModel
  
removeSelectionListener(listener:Function):void
Removes a selection listener.
ButtonModel
  
removeStateListener(listener:Function):void
Removes a state listener.
ButtonModel
  
setArmed(b:Boolean):void
Marks the button as "armed".
ButtonModel
  
setEnabled(b:Boolean):void
Enables or disables the button.
ButtonModel
  
setGroup(group:ButtonGroup):void
Identifies the group this button belongs to -- needed for radio buttons, which are mutually exclusive within their group.
ButtonModel
  
setPressed(b:Boolean):void
Sets the button to being pressed or unpressed.
ButtonModel
  
setRollOver(b:Boolean):void
Sets or clears the button's rollover state
ButtonModel
  
setSelected(b:Boolean):void
Selects or deselects the button.
ButtonModel
Method detail
addActionListener()method
public function addActionListener(listener:Function, priority:int = 0, useWeakReference:Boolean = false):void

Adds a listener to listen the Model's act event. When the button model's armed and pressed to fire this event.

Parameters
listener:Function — the listener
 
priority:int (default = 0) — the priority
 
useWeakReference:Boolean (default = false) — Determines whether the reference to the listener is strong or weak.

See also

org.aswing.event.AWEvent.ACT
addSelectionListener()method 
public function addSelectionListener(listener:Function, priority:int = 0, useWeakReference:Boolean = false):void

Add a listener to listen the Model's selection change event. When the button's selection changed, fired when diselected or selected.

Parameters
listener:Function — the listener
 
priority:int (default = 0) — the priority
 
useWeakReference:Boolean (default = false) — Determines whether the reference to the listener is strong or weak.

See also

org.aswing.event.InteractiveEvent.SELECTION_CHANGED
addStateListener()method 
public function addStateListener(listener:Function, priority:int = 0, useWeakReference:Boolean = false):void

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

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

Buttons always fire programmatic=false InteractiveEvent.

Parameters
listener:Function — the listener
 
priority:int (default = 0) — the priority
 
useWeakReference:Boolean (default = false) — Determines whether the reference to the listener is strong or weak.

See also

org.aswing.event.InteractiveEvent.STATE_CHANGED
isArmed()method 
public function isArmed():Boolean

Indicates partial commitment towards pressing the button.

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

Returns
Boolean — true if the button is armed, and ready to be pressed
isEnabled()method 
public function isEnabled():Boolean

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

Returns
Boolean — true if the button is enabled, and therefore selectable (or pressable)
isPressed()method 
public function isPressed():Boolean

Indicates if button has been pressed.

Returns
Boolean — true if the button has been pressed
isRollOver()method 
public function isRollOver():Boolean

Indicates that the mouse is over the button.

Returns
Boolean — true if the mouse is over the button
isSelected()method 
public function isSelected():Boolean

Indicates if the button has been selected.

Returns
Boolean
removeActionListener()method 
public function removeActionListener(listener:Function):void

Removes a action listener.

Parameters
listener:Function — the listener to be removed.

See also

org.aswing.event.AWEvent.ACT
removeSelectionListener()method 
public function removeSelectionListener(listener:Function):void

Removes a selection listener.

Parameters
listener:Function — the listener to be removed.

See also

org.aswing.event.InteractiveEvent.SELECTION_CHANGED
removeStateListener()method 
public function removeStateListener(listener:Function):void

Removes a state listener.

Parameters
listener:Function — the listener to be removed.

See also

org.aswing.event.InteractiveEvent.STATE_CHANGED
setArmed()method 
public function setArmed(b:Boolean):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.

Parameters
b:Boolean — true to arm the button so it can be selected
setEnabled()method 
public function setEnabled(b:Boolean):void

Enables or disables the button.

Parameters
b:Boolean
setGroup()method 
public function setGroup(group:ButtonGroup):void

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

Parameters
group:ButtonGroup — the ButtonGroup this button belongs to
setPressed()method 
public function setPressed(b:Boolean):void

Sets the button to being pressed or unpressed.

Parameters
b:Boolean
setRollOver()method 
public function setRollOver(b:Boolean):void

Sets or clears the button's rollover state

Parameters
b:Boolean — true to turn on rollover

See also

setSelected()method 
public function setSelected(b:Boolean):void

Selects or deselects the button.

Parameters
b:Boolean — true selects the button, false deselects the button.