0 Replies Latest reply on Oct 14, 2009 12:08 PM by smengs

    defaulButton issue when setting with AS

    smengs

      I have a screen where I am trying to set the defaultButton as the user is working the screen.  For a very simple example, I've taken the defaultButton example code from the adobe livedocs page and altered it to not set the default button on the form tag.  Instead, when the user types an id and password, the Login button becomes enabled and the myForm.defaultButton = mySubmitBtn is performed.

       

      What you will notice when running the modified code is that the button will enable after values are entered in both fields.  But the Login button will not show the border around it indicating it is the default button and the enter key will not work.  If I switch focus from one field to another, after typing in both, the button will gain the border and enter will now work.

       

      Anyone have any thoughts on how to get the Login button to get the indicator that it is the default button and make the enter key work?  I don't want the user to have to tab between fields to make a defaultButton work.

       

      Original version (bottom of page).

      http://livedocs.adobe.com/flex/3/html/help.html?content=containers_intro_3.html

       

      Modified version:

       

      <?xml version="1.0" encoding="utf-8"?>

      <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">

          <mx:Script>

              <![CDATA[

                  public function submitLogin():void {

                      text1.text="You just tried to log in.";

                  }

                  public function checkSubmit():void

                  {

                  if (username.length>0 && password.length>0)

                  {

                    mySubmitBtn.enabled = true;

                    myForm.defaultButton = mySubmitBtn;

                  }

                  }

              ]]>

          </mx:Script>

       

          <mx:Panel title="Default Button Example">

       

              <mx:Form id="myForm">

                  <mx:FormItem label="Username:">

                      <mx:TextInput id="username" width="100"

                      change="checkSubmit()"/>

                  </mx:FormItem>

                  <mx:FormItem label="Password:">

                      <mx:TextInput id="password" width="100" displayAsPassword="true"

                      change="checkSubmit()"/>

                  </mx:FormItem>

                  <mx:FormItem>

                      <mx:Button id="mySubmitBtn" label="Login" click="submitLogin();" enabled="false"/>

                  </mx:FormItem>

              </mx:Form>

              <mx:Text id="text1" width="150"/>

          </mx:Panel>

      </mx:Application>

       

      Thanks,

      scott