Package | fl.managers |
Class | public class FocusManager |
Inheritance | FocusManager ![]() |
Implements | IFocusManager |
Language Version: | ActionScript 3.0 |
Product Version: | Flash CS3 |
Runtime Versions: | Flash Player 9.0.28.0, AIR 1.0 |
A tab loop is typically navigated by using the Tab key; focus moves between the components in the tab loop in a circular pattern from the first component that has focus, to the last, and then back again to the first. A tab loop includes all the components and tab-enabled components in a container. An application can contain numerous tab loops.
A FocusManager instance is responsible for a single tab loop; an application uses a different FocusManager instance to manage each tab loop that it contains, although a main application is always associated with at least one FocusManager instance. An application may require additional FocusManager instances if it includes a popup window, for example, that separately contains one or more tab loops of components.
All components that can be managed by a FocusManager instance must implement the fl.managers.IFocusManagerComponent interface. Objects for which Flash Player manages focus are not required to implement the IFocusManagerComponent interface.
The FocusManager class also manages how the default button is implemented. A default button
dispatches a click
event when the Enter key is pressed on a form,
depending on where focus is at the time. The default button does not dispatch the
click
event if a text area has focus or if a value is being edited in
a component, for example, in a ComboBox or NumericStepper component.
Related API Elements
Property | Defined By | ||
---|---|---|---|
![]() | constructor : Object
A reference to the class object or constructor function for a given object instance. | Object | |
form : DisplayObjectContainer
Base DisplayObjectContainer for the IFocusManager, usually the stage. | FocusManager |
Method | Defined By | ||
---|---|---|---|
![]() |
Indicates whether an object has a specified property defined. | Object | |
![]() |
Indicates whether an instance of the Object class is in the prototype chain of the object specified
as the parameter. | Object | |
![]() |
Indicates whether the specified property exists and is enumerable. | Object | |
![]() |
Sets the availability of a dynamic property for loop operations. | Object | |
![]() |
Returns the string representation of this object, formatted according to locale-specific conventions. | Object | |
![]() |
Returns the string representation of the specified object. | Object | |
![]() |
Returns the primitive value of the specified object. | Object |
form | property |
form:DisplayObjectContainer
Language Version: | ActionScript 3.0 |
Runtime Versions: | AIR 1.0, Flash Player 9.0.28.0 |
Base DisplayObjectContainer for the IFocusManager, usually the stage.
Implementation
public function get form():DisplayObjectContainer
public function set form(value:DisplayObjectContainer):void
To run the example, follow these steps:
- Add the TextInput component to the library.
- Save this code as FocusManagerExample.as in the same directory as your FLA file.
- Set the Document class in the FLA file to FocusManagerExample.
package { import fl.controls.TextInput; import fl.managers.FocusManager; import flash.display.InteractiveObject; import flash.display.Sprite; import flash.events.*; import flash.utils.Timer; public class FocusManagerExample extends Sprite { private var fm:FocusManager; public function FocusManagerExample() { buildGridOfTextInputs(); fm = new FocusManager(this); var t:Timer = new Timer(1000); t.addEventListener(TimerEvent.TIMER,secondPassed); t.start(); } private function buildGridOfTextInputs():void { var rowSpacing:uint = 30; var colSpacing:uint = 110; var totalRows:uint = 4; var totalCols:uint = 3; var i:uint; for(i = 0; i < totalRows * totalCols; i++) { var ti:TextInput = new TextInput() ti.name = "component"+i.toString(); ti.addEventListener(FocusEvent.FOCUS_IN,focusChange); ti.setSize(100,20); ti.x = 10 + ((i % totalCols) * colSpacing); ti.y = 10 + (Math.floor(i / totalCols) * rowSpacing); ti.tabEnabled = true; addChild(ti); } } private function secondPassed(e:TimerEvent):void { var nextComponent:InteractiveObject = fm.getNextFocusManagerComponent(); fm.setFocus(nextComponent); } private function focusChange(e:FocusEvent):void { trace("Focus change: " + e.target.name); } } }
Wed Nov 21 2018, 06:34 AM -08:00