Focus Management and Keyboard Control

Focus management and keyboard control are two related topics in Flex. An object has focus when it can respond to keyboard events. For example, when a text input control has focus the user can enter text into the field. When a component has focus, it generally indicates that focus with a colored border. You can use the keyboard to control focus within a Flex application, and you can also respond to key presses. We’ll look at all of these topics in the next few sections.

Controlling Tab Order

A standard convention of application usability is that pressing the Tab key advances the focus to the next element and Shift-Tab moves focus to the preceding element. This is true of most desktop applications. It is true of most HTML applications. And it is also true of Flex applications.

Many (though certainly not all) Flex components are capable of receiving focus. For example, text inputs, combo boxes, and buttons are all capable of receiving focus. Clearly, there are other types of components that cannot receive focus. For example, a VBox container, a label, or a spacer cannot receive focus because none of these components is capable of responding to keyboard input.

When several focus-enabled components exist on the screen at the same time, there exists a default order by which the user can move focus by pressing the Tab key. The default tab order follows the order in which components were initialized. The following code creates a form with three text inputs ...

Get Programming Flex 3 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.