0

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 !

Devesh
  • 1
  • 2

4 Answers4

0

Try this,

private function onCreationComplete():void {

 textInput.setFocus();

 textInput.setSelection(0,0);

}

Hope it helps.

Subash Selvaraj
  • 3,385
  • 1
  • 14
  • 17
0

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?

Community
  • 1
  • 1
Andrei
  • 571
  • 6
  • 15
  • I have already tried with such kind of tricks. But unfortunately it's only working with IE, not working with FF & Chrome. – Devesh Dec 10 '13 at 09:18
0

Try this. In mxml you can give

focusEnabled = true

Hope it will help

UI Dev
  • 689
  • 2
  • 9
  • 31
0

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();
Sumit
  • 729
  • 4
  • 9
  • Things are almost same here. Anyways, have you tried it at your end ? Because it's not working in FF & Chrome. Working only in IE. – Devesh Dec 10 '13 at 10:31
  • Yes, it is working fine for me. I have the following setup Flex 4.10 sdk IE 11 with flash debbugger version 11,9,900,117 Firefox 25.0.1 with flash debbugger version 11,9,900,117 Chrome 31.0.1650.63 m with flash debbugger version 11,9,900,170 Can you post code for your index.template.html? – Sumit Dec 10 '13 at 11:09
  • It's difficult to share the complete code of index.template.html. So sharing few code snippet. I have this method onLoad on body. – Devesh Dec 10 '13 at 12:27
  • replace the following line in your index.template.html var f=swfobject.getObjectById("${application}"); *double quotes in place of single quotes. I copied your code and pasted, it was not working. Changing to double quotes it is working. – Sumit Dec 10 '13 at 13:41
  • Tried the same. But still same result. Works only in IE. – Devesh Dec 11 '13 at 04:45