AS3 set focus on specific component

Flex60460

I have a form with several component : datagrid, textArea, text input ... For each component FocusIn Event is available.

var objTarget:String;
     protected function memo_focusInHandler(event:FocusEvent):void
            {
                objTarget=event.currentTarget.id;       
}

With memo_focusInHandler, I know which has focus.

My goal is to backup last focus objet, and re open windows with focus on this object. I try to do this :

objTarget.setfocus(); 

But it doesn't work. Could you help to found the best way to reach my goal.

Best regards.

BadFeelingAboutThis

There is no need (that you've shown) to work with the string id reference. It would much simpler (and slightly more efficient) to work directly with the object reference.

var objTarget:Object; // Object instead of type :String

protected function memo_focusInHandler(event:FocusEvent):void {
    objTarget = event.currentTarget;  //instead of the currentTarget's id property, assign the current target itself       
}

Then, when you want to reset focus, you can do:

if(objTarget is TextInput || objTarget is TextArea){  //make sure it's a text input or text area first - optional but recommended if you don't like errors
    objTarget.selectRange(objTarget.text.length, objTarget.text.length); //set cursor to the end
    objTarget.setFocus(); //focus the text input/area
}

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

Set Focus for component in VueJS

Set component focus with RTTI

Set focus on a component with Apache Wicket?

Disable Focus - AS3

Set focus on input field of the form in controlled component

Set focus to element of nested component in Angular 4

How to set the focus on a specific element in a uifigure?

Android - Set TalkBack accessibility focus to a specific view

Set focus onto a specific window using VBScript

Set state on specific component in React

How to remove focus from one magicsuggest component and set focus on second magicsuggest component

How to focus on a specific input text after the component is rendered?

AS3 - Get and Set

Angular 2 Set focus on first field of form on component load

how to set focus for AutoComplete component from PrimeNG library in Angular

How to set focus on a button when react component renders?

Angular set focus to an input that is in a <td> of the table Using table object in component

Can you use @ViewChild to set the focus in a specific text area?

How set focus on specific input text field in Flutter

Set focus in Shiny app to a specific UI element on load

How to set focus to a specific child in a ttk.Treeview similar to clicking on it?

Is there any way to set focus on a specific html control on tab key press?

How to set focus on a specific radio button within an Option Group

How to set a value to a specific component in ReactJs

The useState set method not rendring the specific component

Set focus to an Input in a gwtbootstrap3 Modal

How to set focus to a window in GTK3?

Why is the focus event fired twice from a Vue 3 child component?

Get the index of a datagrid component on rollover in AS3