User Guide
FocusManager class 419
FocusManager class
You can use the Focus Manager 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 it.
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.
Using the Focus Manager
The Focus Manager does not automatically assign focus to a component. You must write a script
that calls
FocusManager.setFocus() on a component if you want a component to have focus
when an application loads.
Note: If you call FocusManager.setFocus() to set focus to a component when an application loads,
the focus ring does not appear around that component. The component has focus, but the indicator is
not present.
To create focus navigation in an application, set the tabIndex property on any objects (including
buttons) that should receive focus. When a user presses the Tab key, the Focus Manager looks for
an enabled object with a
tabIndex property that is higher than the current value of tabIndex.
Once the Focus Manager reaches the highest
tabIndex property, it returns to zero. So, in the
following example, the
comment object (probably a TextArea component) receives focus first, and
then the
okButton object receives focus:
comment.tabIndex = 1;
okButton.tabIndex = 2;
You can also use the Accessibility panel to assign a tab index value.
If nothing on the Stage has a tab index value, the Focus Manager uses the depth (stacking order, or
z-order). The depth is set up primarily by the order in which components are dragged to the
Stage; however, you can also use the Modify > Arrange > Bring to Front/Send to Back commands
commands to determine the final depth.
CHAPTER 6
Components Dictionary