Packagefeathers.utils.keyboard
Classpublic class KeyToSelect
InheritanceKeyToSelect Inheritance Object

Product Version : Feathers 3.0.0

Changes the isSelected property of the target when a key is pressed and released while the target has focus. The target will dispatch Event.CHANGE. Conveniently handles all KeyboardEvent listeners automatically.

In the following example, a custom component will be selected when a key is pressed and released:

public class CustomComponent extends FeathersControl implements IFocusDisplayObject
{
    public function CustomComponent()
    {
        super();
        this._keyToSelect = new KeyToSelect(this);
        this._keyToSelect.keyCode = Keyboard.SPACE;
    }
    
    private var _keyToSelect:KeyToSelect;
// ...

Note: When combined with a KeyToTrigger instance, the KeyToSelect instance should be created second because Event.TRIGGERED should be dispatched before Event.CHANGE.

See also

feathers.utils.keyboard.KeyToTrigger
feathers.utils.touch.TapToSelect


Public Properties
 PropertyDefined By
  cancelKeyCode : uint
The key that will cancel the selection if the key is down.
KeyToSelect
  isEnabled : Boolean
May be set to false to disable selection temporarily until set back to true.
KeyToSelect
  keyCode : uint
The key that will select the target, when pressed.
KeyToSelect
  keyLocation : uint
The location of the key that will select the target, when pressed.
KeyToSelect
  keyToDeselect : Boolean
May be set to true to allow the target to be deselected when the key is pressed.
KeyToSelect
  target : IToggle
The target component that should be selected when a key is pressed.
KeyToSelect
Public Methods
 MethodDefined By
  
KeyToSelect(target:IToggle = null, keyCode:uint)
Constructor.
KeyToSelect
Property Detail
cancelKeyCodeproperty
cancelKeyCode:uint

The key that will cancel the selection if the key is down.

The default value is flash.ui.Keyboard.ESCAPE.


Implementation
    public function get cancelKeyCode():uint
    public function set cancelKeyCode(value:uint):void
isEnabledproperty 
isEnabled:Boolean

May be set to false to disable selection temporarily until set back to true.


Implementation
    public function get isEnabled():Boolean
    public function set isEnabled(value:Boolean):void
keyCodeproperty 
keyCode:uint

The key that will select the target, when pressed.

The default value is flash.ui.Keyboard.SPACE.


Implementation
    public function get keyCode():uint
    public function set keyCode(value:uint):void
keyLocationproperty 
keyLocation:uint

The location of the key that will select the target, when pressed. If uint.MAX_VALUE, then any key location is allowed.

The default value is uint.MAX_VALUE.


Implementation
    public function get keyLocation():uint
    public function set keyLocation(value:uint):void

See also

flash.ui.KeyLocation
keyToDeselectproperty 
keyToDeselect:Boolean

May be set to true to allow the target to be deselected when the key is pressed.

The default value is false.


Implementation
    public function get keyToDeselect():Boolean
    public function set keyToDeselect(value:Boolean):void
targetproperty 
target:IToggle

The target component that should be selected when a key is pressed.


Implementation
    public function get target():IToggle
    public function set target(value:IToggle):void
Constructor Detail
KeyToSelect()Constructor
public function KeyToSelect(target:IToggle = null, keyCode:uint)

Constructor.

Parameters
target:IToggle (default = null)
 
keyCode:uint (default = NaN)