3 Replies Latest reply on Apr 28, 2009 4:20 AM by Madhav Subedi

    TextArea - pasting text into

    toft Level 1

      I have a single line textarea that I will use for pasting text into.

       

      I want to show the text from the start. However, if the text is too long it is

      pushed to the left and out of sight.

       

      How do I set the position back to the start of the text ? (Have tried setSelection(0, 0) but it doesnt work)

        • 1. Re: TextArea - pasting text into
          Madhav Subedi Level 4

          use "selectionBeginIndex" property.

           

          example:

           

          <mx:TextInput id="txt" change="txt.selectionBeginIndex=0;"/>

          • 2. Re: TextArea - pasting text into
            toft Level 1

            Thanks subedimadhav.

             

            However, the problem was the event I used. I tried 'paste' but it turned out to not work at all for my textarea.

            Changing it to the 'change' event makes it work but makes it impossible to write text.

             

            Why isnt the paste event dispatched when pasting text into the textarea ? Anyone ?

            • 3. Re: TextArea - pasting text into
              Madhav Subedi Level 4

              I got the situation.

               

              what i could think in such is to disable the mouse for your input, and check the ctrl+v in every keyboard input.

               

               

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

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

              layout="absolute">

              <mx:Script>

              <![CDATA[

              import mx.controls.Alert;


              private function checkPaste( event:KeyboardEvent ):void

              {

                   if(event.ctrlKey && event.charCode==118)

                   {

                        txt.selectionBeginIndex=0;

                   }

              }

              ]]>

              </mx:Script>

              <mx:TextInput id="txt"

              mouseEnabled="false"

              mouseChildren="false"

              keyUp="checkPaste(event)" />

              </mx:Application>

               

               

              let us know if any other way found.