FocusManager

Kind of class: public class
Package:
Inherits from:
  • EventDispatcher
Classpath: org.asaplibrary.ui.form.focus.FocusManager
File last modified: Friday, 13 May 2011, 22:20:35
Class for managing focus on UI components that implement IFocusable. Use of this class overrides default tab button behaviour. Only UI components added to an instance of this class can get focus through use of the tab key. Consecutive presses on the TAB key will cycle through the list of items in order of addition, unless a specific tab index has been set on any of them. With SHIFT-TAB the list is cycled in reversed order.
Example
  • Suppose two objects of type InputField have been defined on the timeline, with instance names "tName" & "tEmail". Use the following code to allow focus management on them:
    mFocusManager = new FocusManager(LocalController.globalStage);
    mFocusManager.addElement(tName);
    mFocusManager.addElement(tEmail);
    
    Note that a valid stage object must be passed to the FocusManager constructor in order for the tab key to be detected. To set focus to the email field, use the following code: mFocusManager.setFocus(tEmail);
Events broadcasted to listeners

Summary

Constructor
Instance methods
  • clear () : void
    • Clear list of focus elements
  • setFocus (inItem:IFocusable) : void
    • Sets the focus to a specific element.
  • addElement (inItem:IFocusable, inPosition:int = -1) : Boolean
    • Add an item for focus management; optionally set the tab index for the item.
  • toString () : String

Constructor

FocusManager

function FocusManager(inStage:Stage)

Constructor

Parameters
inStage:a valid Stage object. Use LocalController.globalStage for a Stage object that is always valid.

Instance methods

addElement

function addElement(inItem:IFocusable, inPosition:int = -1) : Boolean

Add an item for focus management; optionally set the tab index for the item.

Parameters
inItem :item to be used in focus management
inPosition:zero-based, optional. If ommitted (or set to -1), it will be added to the end of the list. If an element was already found at the position specifed, it will be inserted prior to the existing element
Returns
  • Boolean indicating if addition was successfull.

clear

function clear() : void

Clear list of focus elements

setFocus

function setFocus(inItem:IFocusable) : void

Sets the focus to a specific element.

Parameters
inItem:previously added item

toString

override function toString() : String
Overrides
  • EventDispatcher.toString