0
votes

I am facing one issue related to setFocus() method of UIComponent. I have one textinput and I have written textInput.setFocus() on creationComplete of application i.e.

private function onCreationComplete():void {

 // 1st approach     
 textInput.setFocus();

 // 2nd approach
 textInput.focusManager.setFocus(textInput); 
 textInput.focusManager.showFocus();

}

While using both the approach, I can see that my text input has got a cursor which shows that it has got focus. But issue is that it doesn’t get any input from keyboard until or unless I click on text input manually.

Is this behaviour normal in Flex or is there any issue with Flash Player which I am using or any issue with browser ?

Flex SDK: 4.1

Browser & Flash Player Version

  1. IE 9 with Flash Player debugger version 11.3.300.257...
  2. Chrome 15.0.874.121 with Flash Player 11.1.102.55...
  3. Firefox 20.0.1 with Flash Player 11.9.900.117...

Can anyone please let me know what is the issue? Any input will be highly appreciated !

4
It seems strange... you are actually using an old version of Flex SDK, can you update to at least 4.5?zenbeni
Actually i can't upgrade. Anyways are you sure that it will work if i upgrade to 4.5 or 4.5+ ?Devesh
1. Sorry for this question, but is your input editable? 2. Try to set focus to your input.textDisplayuser1875642
Same issue with Flex SDK 4.9 also.Devesh

4 Answers

0
votes

Try this,

private function onCreationComplete():void {

 textInput.setFocus();

 textInput.setSelection(0,0);

}

Hope it helps.

0
votes

You are setting focus to TextInput inside application, but when web page is loaded flash app doesn't have focus. That's why your app doesn't get any keyboard events.
Try to search how to set focus onto flash app on page load.

Example:
How do I make my flash object get focus on load?

0
votes

Try this. In mxml you can give

focusEnabled = true

Hope it will help

0
votes

This one is working for all broswers(IE, firefox and chrome) In your index.template.html file add the follwing script block

<script>
    function setFocusOnFlash() {
      var f=swfobject.getObjectById('yourFlashObjectId');
      if (f) { f.tabIndex = 0; f.focus(); }
    }
</script>

And call it onload in body tag

<body onload="setFocusOnFlash()">    

On your applicationCreationComplete put below lines

focusManager.setFocus(textInput); 
textInput.focusManager.showFocus();