--- In [email protected], "Alex Harui" <[EMAIL PROTECTED]> 
wrote:
>
> 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
>

Hi Yarin, 
So, this works for me but... it didnt until I added a textInput and
then clicked in it to get focus in the app... but once some control
in the app had focus, a return would cause the alert sent by the 
default button.

i hope this helps.
Brian

<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml";
layout="absolute"
focusEnabled="true"
defaultButton="{this.button1}" >
        <mx:Script>
        <![CDATA[
                
        import mx.controls.Alert;
        private function testClick(event:Event):void {
                Alert.show("got a click from an enter");
        }
                
        ]]>
        </mx:Script>
        
        <mx:VBox>
                <mx:TextInput />
                <mx:Button id="button1" label="b1" x="28" y="19"
                    click="testClick(event)" />
                <mx:Button id="button2" label="b2" x="28" y="49" />
                <mx:Button id="button3" label="b3" x="28" y="79"  />
                <mx:TextInput />
        </mx:VBox>
</mx:Application> 


Reply via email to