2 Replies Latest reply on Dec 7, 2010 1:58 AM by ThePodpea

    Flex 4 TextInput Bug

    ThePodpea

      I have found a problem with the spark TextInput component.

       

      If the TextInput displayAsPassword variable is set to true and the user places a string of characters into the component but then highlights the whole string of characters and pastes a shorter string of characters in, the shorter string of characters only replaces the amount of characters that the pasted string has and maintains the rest of the characters of the longer string.

       

      For example, if I put "paul@podpea.co.uk" into the TextInput, highlight the entire string, then paste "blah" into the TextInput, it would appear that I have four characters within the component. However, when I trace out what is in the TextInput I get "blah@podpea.co.uk". The paste has only replaced the first four characters of the original string!!

       

      I have included some simple code so that you can check this for yourself. If you follow the example above and then press the "Check" button the Alert box will tell you what is actually in the TextInput field:

       

      <?xml version="1.0" encoding="utf-8"?>
      <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
                     xmlns:s="library://ns.adobe.com/flex/spark"
                     xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="955" minHeight="600">
          <fx:Script>
              <![CDATA[
                  import mx.controls.Alert;
              ]]>
          </fx:Script>
          <s:HGroup width="100%" horizontalAlign="center">
              <s:TextInput
                  id="ti"
                  displayAsPassword="true"
                  change="trace(ti.text)"/>
              <s:Button
                  label="Check"
                  click="Alert.show(ti.text);"/>
          </s:HGroup>
         
         
      </s:Application>