Titanium JIRA Archive
Appcelerator Community (AC)

[AC-158] Titanium.UI.TextField.setSelection does not select the text

GitHub Issuen/a
TypeBug
Priorityn/a
StatusResolved
ResolutionCannot Reproduce
Resolution Date2015-11-13T19:18:34.000+0000
Affected Version/sn/a
Fix Version/sn/a
ComponentsTitanium SDK & CLI
Labelsandroid
ReporterPeng Wang
AssigneeShak Hossain
Created2015-06-10T07:57:44.000+0000
Updated2015-11-13T19:18:34.000+0000

Description

Titanium.UI.TextField.setSelection(2, 10) when TextField.value.length = 49 The cursor is set to position 2 retrieved from (TextField.selection.location). However, the TextField.selection.length is 0.

Comments

  1. Amimul Hossain 2015-09-15

    Tested this issue In SDK 4.1.1.GA, Android version 5.1.1, Google Nexus 7. TextField.setSelection is working as expected. CODE SAMPLE
       var win = Ti.UI.createWindow({
         backgroundColor: 'white'
       });
       
       var textField = Ti.UI.createTextField({
         borderStyle: Ti.UI.INPUT_BORDERSTYLE_ROUNDED,
         color: '#224466',
         top: 10, left: 10,
         width: 250, height: 60
       });
       
       var button = Titanium.UI.createButton({
          title: 'Hello',
          top: 80,
          width: 100,
          height: 50
       });
       
       button.addEventListener('click',function(e)
       {
          textField.setSelection(2, 10);
       });
       
       win.add(textField);
       win.add(button);
       win.open();
       
    You can try to use the latest SDK if you still run into this error.

JSON Source