2 Replies Latest reply on May 3, 2011 7:20 AM by Andrei Kouzmenkov

    Any way to manipulate Insert/Replace mode in TextInput?

    Andrei Kouzmenkov Level 1

      Is it possible to programmatically set Replace mode in TextInput (MX, SDK 3.5) without the user having to press INSERT keyboard button?

      In some cases I'd like to always overwrite text in the input, or at least overwrite it by default.

       

      Thanks.

        • 1. Re: Any way to manipulate Insert/Replace mode in TextInput?
          Shravan P Level 1

          set an empty string to textInput's click property.

           

          txt.text = " ";

           

          <mx:TextInput id="txt" text="click here to erase this text" click="clearText(event);"/>

           

          Check out this example:

           

          <mx:Script>

          <![CDATA[

           

          import mx.controls.Alert;

           

          private function clearText(event:Event):void{

                    txt.text =" ";

          }

           

          private function showNewText(event:Event):void{        

                    Alert.show("New text: " +txt.text);

          }

           

          ]]>

          </mx:Script>

           

          <mx:VBox width="100%" height="100%" verticalGap="20" > <mx:TextInput id="txt" text="click here to erase this text" click="clearText(event);"/>

           

           

          <mx:Button id="showNewTxt" label="Show Newly Entered Text" click="showNewText(event);" />

           

          </mx:VBox>

           

          -Shravan P.

           

          Message was edited by: Shravan P

          • 2. Re: Any way to manipulate Insert/Replace mode in TextInput?
            Andrei Kouzmenkov Level 1

            Shravan, that's not what I mean.

             

            Let's say we have a TextInput control on a form with a text, e.g. formatted time "00:00" and maxChars=5.

            Now when the user needs to enter time and starts typing. But that doesn't work because by default UITextInput, which is used by TextInput, which extends FlexTextField, which extends flash.text.TextField tries to insert characters. As flash.text.TextField is not open source I can't see how it works.

             

            There is (at least on PC) Insert key, which changes typing mode from Insert to Replace. In replace mode entering such restricted text is a breeze.

            Yes, there may be tricks like manipulating selection after each character typed, but ideally I'd like to force the input into Replace mode.

            If users want Insert they always can switch back.

             

            But I don't see any control over I/R typing mode, and wonder if there is a way to manipulate it.

             

            Thanks.