You can call setFocus() on the creationComplete event for the TextInput.
Here is an example:

 

            private function createTI(): void

            {

                var newTI:TextInput = new TextInput();

                newTI.addEventListener("creationComplete", setInFocus);

                addChild(newTI);

            }

 

            private function setInFocus(event:FlexEvent): void

            {

                event.target.setFocus();

            }

 

Joan

 

________________________________

From: [email protected] [mailto:[EMAIL PROTECTED] On
Behalf Of Charles Galpin
Sent: Thursday, June 14, 2007 7:24 PM
To: [email protected]
Subject: [flexcoders] setFocus on TextInput created in AS

 

Hopefully this is just me being a bonehead, but when creating a 
TextInput in actionscript, it appears you can't call setFocus() on it 
until some point in the future when the internal text field has been 
created.

I'm not sure when I can know it's safe to set the focus on it, but 
I'd like to put the focus on it after I create it. If it matters, 
this is for a custom item editor.

thanks
charles
p.s. Flex guys, I'd think this is a bug in TextInput.setFocus() to 
not check that textField is not null.

 

Reply via email to