FocusManager class

You can use the Focus Manager class to specify the order in which components receive focus when a user presses the Tab key to navigate in an application. You can also use the Focus Manager to set a button in your document that receives keyboard input when a user presses Enter (Windows) or Return (Macintosh). For example, when users fill out a form, they should be able to tab between fields and press Enter (Windows) or Return (Macintosh) to submit the form.

All components implement Focus Manager support; you don't need to write code to invoke the FocusManager class.

NOTE

 

The FocusManager class is supported only if you are working in a document that specifies ActionScript 2.0 in its Publish Settings.

TIP

 

Focus Manager support overrides the use of the on(keyPress) global handler. Because all components implement Focus Manager, an application that includes components and uses the on(keyPress) global handler needs to have a tabIndex for every control (including components and movie clips) set, explicitly (see Using Focus Manager). Or, preferably, you can add an event listener for a specific Key and the Focus Manager will not override the corresponding event handler. For more information about creating an event listener for a Key, see "Capturing keypresses" in Learning ActionScript 2.0 in Adobe Flash.

The Focus Manager interacts with the System Manager, which activates and deactivates FocusManager instances as pop-up windows are activated or deactivated. Each modal window has an instance of FocusManager so the components in that window become their own tab set, preventing the user from tabbing into components in other windows.

The Focus Manager recognizes groups of radio buttons (those with a defined RadioButton.groupName property) and sets focus to the instance in the group that has a selected property that is set to true. When the Tab key is pressed, the Focus Manager checks to see if the next object has the same group name as the current object. If it does, it automatically moves focus to the next object with a different group name. Other sets of components that support a groupName property can also use this feature.

The Focus Manager handles focus changes caused by mouse clicks. If the user clicks a component, that component is given focus.

TIP

 

When testing a script using Focus Manager (Control > Test Movie), select Control > Disable Keyboard Shortcuts in test mode; otherwise, Focus Manager does not appear to work. Also, tabbing and keyboard shortcuts are used by the authoring environment by default. So, if you use test mode, the tab navigation, Enter key, and other key combinations may perform in unexpected ways or appear to fail. Those features should be tested in the Player outside the authoring environment.

Related topics


Flash CS3


 

Send me an e-mail when comments are added to this page | Comment Report

Current page: http://livedocs.adobe.com/flash/9.0/main/00003119.html