O'Reilly logo

Programming Flex 2 by Joey Lott, Chafic Kazoun

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 application convention 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 can respond 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 order always moves from left to right, top to bottom. The following code creates a form with three text inputs and a button. The first two text inputs are ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required