MX2004 Components (1): Focus Manager

zhaozj2021-02-12  157

? Inheritance relationship? UIObject ---> uicomponent ---> FocusManager

? Package? Mx.manager.focusmanager

? One example first? 1)? Drag a button and a TextInput component to the stage. And name OKButton and Input_TXT? 2)? In the timeline first write:? Okbutton.tabindex = 1;? Input_txt.tabindex = 2; // Set the TabINDEX attribute of the two components, ie, press the TAB button to switch Order? Focusmanager.setfocus (input_txt); // When the program is running in input_txt? Focusmanager.defaultpushbutton = okbutton; // When the user presses Enter (Windows) or return (Macintash), focus Okbutton ? var? LO = new? Object (); // Define an Object Object to create listner? lo.click = function (evt) {??? trace (evt.target "was clicked");?}? Okbutton .addeventListener ("Click", LO); // Trigger a Click event when okbutton presses

FocusManager manages the focus order relationship of all component components in 2004. It can specify the order in which each component is in a project (that is, when we press the Tab button)

• All components have inherited the method and properties of the FocusManager class, but you don't need to call it directly with AS. • Focusmanager can also interact with SystemManager. It can activate a pop-up window (POP_UP) or let it lose the focus. Each dialog window is an instance of a FocusManager class. Therefore, the components in the dialog window have their own TAB order, that is, the TAB sequence in the A pop-up window and the TAB secondary charge of the B pop-up window do not affect each other.

For a special case: radiobutton, FocusManager is handled in this way: radio button has a groupname property, when FocusManager processes to Radiobutton, it will focus the focus on the selected single button. , (SELECTED == true), then press the Tab button to continue, it will not focus on another radio button with the same groupname, but the next set of radio buttons with different groupname or another component

• Regardless of how the component's TabIndex is defined, as long as there is a mouse click event (when the mouse click on a component), FocusManager will focus on the component you clicked.

FocusManager is not automatically focused in advance, for example: A, B, C three components in one project, when you open this project, FocusManager does not automatically give A, or B or C Focus By default, there is no focus unless you use FocusManager.SetFocus (instanceName) to give a component preset focus.

? [b] Using Focus Manager [FocusManager] [/ B]

• You can use the TabIndex property to customize the switching order for components in your project. When the user clicks on the Tab key, FocusManage automatically focuses on components that are larger than the TabINDEX value of the current component. If Tabindex's attribute value reaches the maximum, then it will return 0; for example, okbutton is a Button component, input_txt Is a TextInput component? Okbutton.tabindex = 1;? Input_txt.tabindex = 2 ;? Then when the user presses the Tab key, okbutton will accept the focus first, and then INPUT_TXT, if you want users to press Enter (Window) or Return (Macintosh) button is focused to OKButton, then you can implement it with the defaultpushbutton property? Focusmanager.defaultpushbutton = okbutton;? FocusManager has a SendDefaultpushButtonevent () method requires special instructions. The role of this method is to send a Click event to the component defined as FocusManager.defaultpushbutton. Demo first:

? name_txt.tabindex? =? 1;? password_txt.tabindex? =? 2;? chb.tabindex? =? 3;? Submit_ib.tabindex? =? 4; focusmanager.defaultpushbutton? =? Submit_ib; // Here, DEFAULTPUSHBUTTON attribute? ChBobj? =? new? Object (); chain chbobj.click?=?function (O) ?i (chb.selected ===?=?"jody "; PASSWORD_TXT.TEXT? =? "foobar"; focusmanager.senddefaultpushbuttonevent (); // Trigger the Click event defined on the submit_ib when the user presses Enter (Window) or Return (Macintash)?}? else? {? Name_txt.text? =? "" "Password_txt.text? =?" "" ""}?}? chb.addeventlistener ("click",? chbobj); submitobj? =? new? Object (); submitobj. Click? =? Function (o) {? if? (password_txt.text?! =? "foobar") {? trace ("error? on? submit") ;?}? else? {? trace ("yeah !? SendDefaultpushbuttonevent? worked! ");?}?}? submit_ib.addeventlistener (" click ", submitobj);

? Screen.width / 2) this.width = screen.width / 2 "vSpace = 2 border = 0>

Other methods and attributes about the Focusmanager class can check the Components Directory, the method of learning is from the framework, when the details can be "do not seek", when doing things, you can use it while doing.

This series is my understanding of myself. I hope everyone is correct.

转载请注明原文地址:https://www.9cbs.com/read-6314.html

New Post(0)