HelpNearMe
asked on
Flex 4.5 Spark textInput get focus
Hi Experts,
I have a little test app that I am playing with and when it loads in the browser I would like the textinput box to have focus so I can start typing and the characters and they appear in the textbox without first clicking the textbox.
My current code brings focus to the textinput but doesn't allow me to start typing without first clicking the text box. I just want to load the page and if I immediately begin typing, the characters appear in the textbox.
How can I correct this?
Thanks!
HNM
I have a little test app that I am playing with and when it loads in the browser I would like the textinput box to have focus so I can start typing and the characters and they appear in the textbox without first clicking the textbox.
My current code brings focus to the textinput but doesn't allow me to start typing without first clicking the text box. I just want to load the page and if I immediately begin typing, the characters appear in the textbox.
How can I correct this?
Thanks!
HNM
<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
width="240" minWidth="240" minHeight="600" pageTitle="test app" creationComplete="creationCompleteHandler()">
<fx:Script>
<![CDATA[
import spark.components.Label;
private function creationCompleteHandler():void
{
focusManager.setFocus(scannedBarcode);
}
protected function button1_clickHandler(event:MouseEvent):void
{
// TODO Auto-generated method stub
var barcodeEcho:Label = new Label();
barcodeEcho.text = scannedBarcode.text;
container.contentGroup.addElement(barcodeEcho);
}
]]>
</fx:Script>
<fx:Declarations>
<!-- Place non-visual elements (e.g., services, value objects) here -->
</fx:Declarations>
<s:BorderContainer id="container" height="300" width="240" borderStyle="inset"
borderColor="#cccccc" borderWeight="4">
<s:layout>
<s:VerticalLayout>
</s:VerticalLayout>
</s:layout>
<s:TextInput id="scannedBarcode"/>
<s:Button label="Echo Barcode" click="button1_clickHandler(event)"/>
</s:BorderContainer>
</s:Application>
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
You cant, the flash container needs a click to get focus first. Its a common questions, there are work arounds for some browsers but not all.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Still trying these solutions.. I'll be back soon. Thanks
ASKER
Thanks for the help. I'm having some serious problems just getting flash to work on the handheld. So I'm going to close this question. Thanks again.