1 Reply Latest reply on Aug 15, 2006 9:28 AM by jmortimer

    defaultButton not working

    jmortimer
      Below are two bits of code. The first works perfectly. The same <FORM> block is used in the second piece of code, but the "defaultButton" doesn't work at all. I can't figure it out. Please help. The only difference I can see is the first clicks to a AS script and the other clicks to a HTTPService.send. But with either one, when I click the button with my mouse, they work.

      -----------------------------------------------------------
      1.
      <?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";
      }
      ]]>
      </mx:Script>
      <mx:Panel title="Default Button Example">

      <mx:Form width="238" defaultButton="{searchButton}">
      <mx:FormItem label="Last Name:" fontWeight="bold">
      <mx:TextInput width="120" id="lName"/>
      </mx:FormItem>
      <mx:FormItem label="First Name:" fontWeight="bold">
      <mx:TextInput width="120" id="fName"/>
      </mx:FormItem>
      <mx:FormItem label="HBS ID:" fontWeight="bold">
      <mx:TextInput width="120" id="HBS"/>
      </mx:FormItem>
      <mx:FormItem>
      <mx:Button label="Search" id="searchButton" click="submitLogin();"/>
      </mx:FormItem>
      </mx:Form>

      <mx:Text id="text1" width="150"/>
      </mx:Panel>
      </mx:Application>
      ---------------------------------------------------
      2.
      <?xml version="1.0" encoding="utf-8"?>
      <mx:VBox xmlns:mx=" http://www.adobe.com/2006/mxml" height="100%" width="278" creationComplete="quickSearch.send()">
      <mx:HTTPService id="quickSearch" url=" http://localhost/flexInfusion/php/quickSearch.php" useProxy="false" method="POST">
      <mx:request xmlns="">
      <lName>
      {lName.text}
      </lName>
      <fName>
      {fName.text}
      </fName>
      <HBS>
      {HBS.text}
      </HBS>
      </mx:request>
      </mx:HTTPService>
      <mx:Script>
      <![CDATA[
      private function nameFunction(item:Object):String
      {
      return item.lName + ", " + item.fName + " :: " + item.HBS;
      }
      ]]>
      </mx:Script>
      <mx:Panel width="278" height="542" layout="absolute" title="Search">

      <mx:Form width="238" defaultButton="{searchButton}">
      <mx:FormItem label="Last Name:" fontWeight="bold">
      <mx:TextInput width="120" id="lName"/>
      </mx:FormItem>
      <mx:FormItem label="First Name:" fontWeight="bold">
      <mx:TextInput width="120" id="fName"/>
      </mx:FormItem>
      <mx:FormItem label="HBS ID:" fontWeight="bold">
      <mx:TextInput width="120" id="HBS"/>
      </mx:FormItem>
      <mx:FormItem>
      <mx:Button label="Search" id="searchButton" click="quickSearch.send();"/>
      </mx:FormItem>
      </mx:Form>

      <mx:HRule width="238" y="146"/>
      <mx:List id="lsquickSearch" x="0" y="146"
      dataProvider="{quickSearch.lastResult.patientSearch.patient}" labelFunction="nameFunction" width="238" height="300">
      </mx:List>
      <mx:Button x="0" y="454" label="Select"/>
      </mx:Panel>
      </mx:VBox>
        • 1. defaultButton not working
          jmortimer Level 1
          Could it be because the <Form> container is inside of an accordian?

          Because the following code doesn't work either?

          ---------------
          <?xml version="1.0" encoding="utf-8"?>
          <mx:Application xmlns:mx=" http://www.adobe.com/2006/mxml" layout="absolute">
          <mx:Accordion x="358" y="119" width="329" height="390">
          <mx:Canvas label="Accordion Pane 1" width="100%" height="100%">
          <mx:Script>
          <![CDATA[
          public function submitLogin():void {
          text1.text="You just tried to log in";
          }
          ]]>
          </mx:Script>
          <mx:Panel title="Default Button Example" x="10" y="10">
          <mx:Form width="238" defaultButton="{searchButton}">
          <mx:FormItem label="Last Name:" fontWeight="bold">
          <mx:TextInput width="120" id="lName"/>
          </mx:FormItem>
          <mx:FormItem label="First Name:" fontWeight="bold">
          <mx:TextInput width="120" id="fName"/>
          </mx:FormItem>
          <mx:FormItem label="HBS ID:" fontWeight="bold">
          <mx:TextInput width="120" id="HBS"/>
          </mx:FormItem>
          <mx:FormItem>
          <mx:Button label="Search" id="searchButton" click="submitLogin();"/>
          </mx:FormItem>
          </mx:Form>
          <mx:Text id="text1" width="150"/>
          </mx:Panel>
          </mx:Canvas>
          </mx:Accordion>
          </mx:Application>