1 Reply Latest reply on Jun 13, 2006 2:27 AM by RajeshBhadra

    Removing focus

    wrangler1
      I have some form fields. I would like to remove focus from a field when:
      - the enter key is pressed
      - the mouse is clicks outside a field

      How?
        • 1. Re: Removing focus
          RajeshBhadra Level 1
          are you looking for this... i not done the mouse click part but the remove focus have been done in this example...if the answer is not satisfying you can be send message again.


          <?xml version="1.0" encoding="utf-8"?>
          <mx:Application xmlns:mx=" http://www.adobe.com/2006/mxml" layout="absolute" creationComplete="initApp()">
          <mx:Panel title="Details" width="100%" height="100%">

          <mx:Script>
          import mx.managers.FocusManager;

          public function initApp():void
          {
          defaultButton = MyButton;
          fname.setFocus();

          }



          public function action():void
          {
          append.text =fname.text + " " + dob.text +" " + email.text +" " +
          age.text +" " + ssn.text +" " + zip.text +" " + phone.text;
          MyButton.setFocus();



          }

          </mx:Script>






          <mx:Form width="100%" height="100%">
          <mx:FormItem label="First name">
          <mx:TextInput id="fname" width="200"/>
          </mx:FormItem>

          <mx:FormItem label="Date of birth (dd/mm/yyyy)">
          <mx:TextInput id="dob" width="200"/>
          </mx:FormItem>

          <mx:FormItem label="E-mail address">
          <mx:TextInput id="email" width="200"/>
          </mx:FormItem>

          <mx:FormItem label="Age">
          <mx:TextInput id="age" width="200"/>
          </mx:FormItem>

          <mx:FormItem label="SSN">
          <mx:TextInput id="ssn" width="200"/>
          </mx:FormItem>

          <mx:FormItem label="Zip">
          <mx:TextInput id="zip" width="200"/>
          </mx:FormItem>

          <mx:FormItem label="Phone">
          <mx:TextInput id="phone" width="200"/>
          </mx:FormItem>

          <mx:FormItem label="Phone">
          <mx:TextInput id="append" width="400" height="200" editable="false"/>
          </mx:FormItem>
          <mx:FormItem>
          <mx:Button id="MyButton" label="Button" click="action()"/>
          </mx:FormItem>

          </mx:Form>
          </mx:Panel>
          </mx:Application>