4 Replies Latest reply on Mar 7, 2012 2:01 PM by Carol L. Frampton

    Focus in textInput

    jfb00 Level 3

      Hi all,

      I have an extended textInput component.

      How can I select all text (highlight) when user click on this component?

      I try setFocus but it doesn't work.


      override protected function focusInHandler(event:FocusEvent):void


                      //Update component text real value (realValue is a number that comes from my DB.

                      super.text = _realValue.toString();




      any ideas?


        • 1. Re: Focus in textInput
          Flex harUI Adobe Employee

          There should be APIs to set the selection range.  They have different names for Spark vs MX.

          • 2. Re: Focus in textInput
            jfb00 Level 3

            Thanks for you reply and help Alex,

            I try this:




            It does the selection for a second and point the cursor to the zero location after.

            Something else is missing?

            • 3. Re: Focus in textInput
              Flex harUI Adobe Employee

              Try using callLater to delay setting the selection.

              • 4. Re: Focus in textInput
                Carol L. Frampton Level 2

                You want to do something like




                            protected function textinput1_focusInHandler(event:FocusEvent):void








                    <s:TextInput id="textinput1" text="focusIn test" focusIn="textinput1_focusInHandler(event)"/>


                because the RichEditableText focusInHandler sets the selection based on a number of factors.  If you always want everything selected you need to do it after this.