FocusManager

Kind of class:class
Inherits from:Dispatcher
Author:Martijn de Visser
Classpath:org.asapframework.management.focus.FocusManager
File last modified:Sunday, 05 November 2006, 11:21:55
Class to manage focus between various UI elements, without the need of MM's focus manager (which requires elements to be derived from UIComponent class). Listens to TAB key for forward navigation and SHIFT-TAB for backward navigation.
Events broadcasted to listeners:
Usage:
  • You may need to add the 'SeamlessTabbing' parameter to the <object> tag. From Macromedia: (http://www.macromedia.com/support/documentation/en/flashplayer/7/releasenotes.html#Fixes) The default value is true; set this parameter to false to disable "seamless tabbing", which allows users to use the Tab key to move keyboard focus out of a Flash movie and into the surrounding HTML (or the browser, if there is nothing focusable in the HTML following the Flash movie). ActiveX Flash Player has supported seamless tabbing since version 7.0.14.0.

Summary


Constructor
Instance properties
Instance methods
  • clear : Void
    • Clears list of focus elements
  • setFocus (inElement:IFocus) : Void
    • Sets the focus to a specific element.
  • addElement (inElement:IFocus, inPosition:Number) : Boolean
    • Set the TAB index for an interface element.
  • nextFocus : Void
    • Sets focus to next item in list.
  • prevFocus : Void
    • Sets focus to previous item in list.
  • changeFocus (inPrevFocus:Number, inNewFocus:Number) : Void
    • Changes the focus the 'index' passed
  • checkFocus : Number
    • Checks if any of our elements has focus and returns its index
  • kill : Void
    • Kills the link to the Key object so the FocusManager can be removed by garbage collection.
  • getElements : Array
  • toString : String
Event handlers
  • onKeyUp : Void
    • Listens to SHIFT / TAB key.

Constructor

FocusManager

function FocusManager (
inListener:Object)

Constructor. IMPORTANT: when using FocusManager in a MovieClip, the manager will remain in memory (and active) when the clip is removed (due to listening to Key object). Use kill to remove the listener.
Parameters:
listener:
object (optional) which will receive events.
Usage:
  • var myFocus:FocusManager = new FocusManager();
    myFocus.addEventListener(FocusEvent.ON_CHANGE_FOCUS, EventDelegate.create(this, onChangeFocus));

    The following code makes the object that instantiates the FocusManager the default listener. It will receive the onChangeFocus event.

Instance properties

mFocusIndex

private mFocusIndex:Number
(read)

mFocusList

private mFocusList:Array
(read)

Instance methods

addElement

function addElement (
inElement:IFocus, inPosition:Number) : Boolean

Set the TAB index for an interface element.
Parameters:
inElement :
Must implement the IFocus interface.
inPosition:
zero-based, optional. If ommitted, it will be added to the end of the list. If an element was already found at the position specifed, it will be inserted.
Returns:
  • Boolean indicating if addition was successfull.
Usage:
  • formFocus.addElement(to_name, 0);
    formFocus.addElement(to_email, 1);
    formFocus.addElement(to_city, 2);

changeFocus

private function changeFocus (
inPrevFocus:Number, inNewFocus:Number) : Void

Changes the focus the 'index' passed
Events broadcasted to listeners:
  • FocusEvent with type: ON_CHANGE_FOCUS
    • Constant name of the event being sent

checkFocus

private function checkFocus (
) : Number

Checks if any of our elements has focus and returns its index

clear

function clear (
) : Void

Clears list of focus elements

getElements

function getElements (
) : Array

Returns:
  • List of all elements managed by this FocusManager

kill

function kill (
) : Void

Kills the link to the Key object so the FocusManager can be removed by garbage collection. Best used in onUnload event of MC where FocusManager is instantiated in.

nextFocus

private function nextFocus (
) : Void

Sets focus to next item in list.

prevFocus

private function prevFocus (
) : Void

Sets focus to previous item in list.

setFocus

function setFocus (
inElement:IFocus) : Void

Sets the focus to a specific element.
Parameters:
inElement:
Must implement the IFocus interface.
Usage:
  • var formFocus:FocusManager = new FocusManager();
    formFocus.addElement(to_name, 0);
    formFocus.addElement(to_email, 1);
    formFocus.setFocus(to_name);

toString

function toString (
) : String

Event handlers

onKeyUp

function onKeyUp (
) : Void

Listens to SHIFT / TAB key.