Skip to main content
Participant
November 22, 2008
Question

setFocus doesn't work.

  • November 22, 2008
  • 2 replies
  • 386 views
Hello, everyone!

<?xml version="1.0" encoding="utf-8"?>
<mx:Canvas
xmlns:mx=" http://www.adobe.com/2006/mxml"
xmlns:ns1="com.something.*"
creationComplete="init();">

<mx:HBox>
<ns1:MyButton label="ok" click="ok_()" id="OKBtn"/>
<ns1:MyButton label="cancel"click="cancel_()" id="CANCELBtn"/>
</mx:HBox>
<!-- something else -->

<mx:Script>
<![CDATA[

// import statements

public function init():void
{
focusManager.activate(); // Doesn't work;
this.OKBtn.setFocus(); // Doesn't work;
}

]]>
</mx:Script>
</mx:Canvas>

// MyButton Class
public class MyButton extends Button
{
public function MyButton()
{
super();
}
}

Anything else I can try?
This topic has been closed for replies.

2 replies

Y_ChenAuthor
Participant
November 28, 2008
Sorry for the late response !!

Thank you very much.
It works with 'stage.focus = OKBtn;'.
Ned Murphy
Legend
November 22, 2008
It's a little hard (for me) to interpret what you are doing, so I can't guarantee you can code it exactly this way, but generally speaking...

stage.focus = OKBtn;