2 Replies Latest reply on Nov 10, 2009 3:33 AM by amol bhandwale

    set focus to addpopup

    amol bhandwale

      Hi All,

       

      I am trying to display popup on focus in of textarea.

      here is my sample code

      <?xml version="1.0"?>
      <!-- Simple example to demonstrate the TextArea control. -->
      <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml">
          <mx:Script>
              <![CDATA[
                  import mx.managers.PopUpManager;
                  import mx.core.IFlexDisplayObject;
                  public var popUpWindow:IFlexDisplayObject;
                  public function openTwindow():void
                  {
                      popUpWindow = PopUpManager.createPopUp(this, T1 , false);
                      PopUpManager.centerPopUp(popUpWindow);
                  }
              ]]>
          </mx:Script>
          <mx:Button label="Click" click="openTwindow()" />
         
      </mx:Application>

       

      and

      T1.mxml

       

      <?xml version="1.0" encoding="utf-8"?>
      <mx:TitleWindow xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" width="400" height="300">
      <mx:Script>
          <![CDATA[
              import mx.managers.PopUpManager;
              public var textArea : TextArea;
              public function showTextArea():void
               {
                  textArea = new TextArea();
                  textArea.text = TextArea1ID.text;
                  textArea.height = 200;
                  textArea.width = TextArea1ID.width;
                  textArea.addEventListener(FocusEvent.FOCUS_OUT, Removewindow1);
                  textArea.addEventListener(MouseEvent.MOUSE_OUT, Removewindow2);
                  PopUpManager.addPopUp(textArea, TextArea1ID, true);
                  PopUpManager.centerPopUp(textArea);
               }
              
               private function Removewindow1(e:FocusEvent):void
              {
                  TextArea1ID.text = textArea.text;
                  PopUpManager.removePopUp(textArea);
                  TextInp1Id.setFocus();
              }
             
              private function Removewindow2(e:MouseEvent):void
              {
                  TextArea1ID.text = textArea.text;
                  PopUpManager.removePopUp(textArea);
                  TextInp1Id.setFocus();
              }

       

          ]]>
      </mx:Script>
          <mx:Form width="100%" height="100%">
              <mx:FormItem label="Texr Input 1">
                  <mx:TextInput />
              </mx:FormItem>
              <mx:FormItem label="Text Area 1">
                  <mx:TextArea id="TextArea1ID" focusIn="showTextArea()"/>
              </mx:FormItem>
              <mx:FormItem label="Text Input 1">
                  <mx:TextInput id="TextInp1Id"/>
              </mx:FormItem>
          </mx:Form>
      </mx:TitleWindow>

       

      When user focus in text area TextArea1ID it's displaying a popup but not setting the focus.

       

      Thanks,

      Amol.