You should rarely need to set focusEnabled.  Setting it on Application
can screw up the focus logic.  It doesn't totally solve the problem,
though, which I would solve like this:

 

<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml";

layout="absolute" creationComplete="defaultButton=button1;
button1.setFocus()"

> 

<mx:Button id="button1" x="28" y="19" />

<mx:Button id="button2" x="28" y="49" />

<mx:Button id="button3" x="28" y="79" />

</mx:Application>

 

________________________________

From: [email protected]
[mailto:[EMAIL PROTECTED] On Behalf Of y_kessler
Sent: Monday, January 14, 2008 10:32 AM
To: [email protected]
Subject: [flexcomponents] Pressing 'Enter' to click a default button

 


Hello all, I'm at the end of my rope here...

Trying to simply have a default button on my login form that gets 
clicked when a user presses the 'Enter' key. According the the 
documentation, the following code should work:

<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml
<http://www.adobe.com/2006/mxml> "
layout="absolute"
focusEnabled="true"
defaultButton="{this.button1}"
>
<mx:Button id="button1" x="28" y="19" focusEnabled="true"/>
<mx:Button id="button2" x="28" y="49" focusEnabled="true"/>
<mx:Button id="button3" x="28" y="79" focusEnabled="true"/>
</mx:Application> 

But I'm not getting anywhere with this. The button doesn't show up 
with any default highlight, and doesn't respond to key presses. If I 
set the FocusManager.defaultButton directly, I can see a default 
highlight on the button, but it still doesn't respond to key presses.

Finally, I decided I would just capture the keystroke, and perform 
the click programmatically in ActionScript, but there's not even a 
way to do that! 

Absolutely stumped. Anybody?

Thanks---
Yarin

 

Reply via email to