How do I set a focus property on a TextInput that is built using AddChild?

Posted by Huuuze on Stack Overflow See other posts from Stack Overflow or by Huuuze
Published on 2009-05-12T17:11:00Z Indexed on 2010/05/07 21:38 UTC
Read the original article Hit count: 135

Filed under:
|
|

I have the following MXML:

<mx:State name="myState">
    <mx:AddChild relativeTo="{myhbox}" position="after">
    	<mx:Box verticalAlign="middle" horizontalAlign="center" width="100%" height="100%">
    		<mx:Form id="myForm" width="479" verticalScrollPolicy="off" horizontalScrollPolicy="off">
    			<mx:FormItem label="My Label:" fontWeight="bold" id="myLabel" direction="vertical">
    				<mx:TextInput id="myTextInput" width="282" />
    					<mx:HBox>
    						<mx:Button label="Go" click="go();" id="goButton" />
    					</mx:HBox>
    			</mx:FormItem>
    		</mx:Form>
    	</mx:Box>
    </mx:AddChild>
</mx:State>

How do I set focus on the TextInput field using <mx:SetProperty/>? I've tried the following, but it only results in the field being highlighted -- the cursor does not appear in the TextInput:

<mx:SetProperty target="{stage}" name="focus" value="{myTextInput}"/>

Long story short, I want the cursor to appear in the field.

UPDATE: I figured it out. See comments for solution.

© Stack Overflow or respective owner

Related posts about flex

Related posts about flex3