Uploaded image for project: 'Titanium SDK/CLI'
  1. Titanium SDK/CLI
  2. TIMOB-19639

Android: TextField setSelection(0,end) has to be called twice to select text

    Details

    • Story Points:
      5
    • Sprint:
      2016 Sprint 08 SDK

      Description

      When trying to select the whole text in a TextField I use the setSelection function:

      function selectText(e){
         $.tf_1.setSelection(0,$.tf_1.value.length)
      }
       
      $.btn.addEventListener("click",selectText)
      $.index.open();
      

      <Alloy>
      	<Window class="container">
      		<TextField id="tf_1" value="123456"></TextField>
      		<Button id="btn">Select text</Button>
      	</Window>
      </Alloy>
      

      "TextField": {
          right:50,
          left:50,
          color:"black"
      }
      ".container": {
          layout:"vertical",
          backgroundColor:"white"
      }
      

      It's only working when the cursor is at the beginning. When it's in the middle or end it will just move the cursor to front and I have to click the button again to select the text.
      From the function call (0, length) I expect to start from 0 and select the whole text in one go

      Android 5 (Nexus 4)
      SDK 5.0.0.GA

      Workaround:
      use

      function selectText(e){
        $.tf_1.setSelection(0,$.tf_1.value.length)
        _.delay(function(){
          $.tf_1.setSelection(0,$.tf_1.value.length)
        },200);
      }
      

        Attachments

          Activity

            People

            • Assignee:
              hknoechel Hans Knöchel
              Reporter:
              michael Michael Gangolf
              Reviewer:
              Hans Knöchel
            • Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Backbone Issue Sync

                • Titanium SDK/CLI <> Titanium Mobile
                  Synced with:
                  TIMOB-20438
                  Sync status:
                  ERROR
                  Last received:
                  Last sent:

                  Git Integration