Expected behavior
Per the docs, setSelection() takes two parameters, start and end, in that order. Thus, to select all the text in a text field, I would expect to use setSelection(0, $.txt.value.length)
http://docs.appcelerator.com/titanium/latest/#!/api/Titanium.UI.TextField-method-setSelection
Actual behavior
On Android, it appears that those parameters are reversed. The following code will select all the text in the text field on iOS & Android
$.txt.addEventListener('focus', function(e) {
if(OS_IOS) {
$.txt.setSelection(0,$.txt.value.length);
} else {
// params are backward on Android
$.txt.setSelection($.txt.value.length, 0);
}
});
Both setSelection(0, $.txt.value.length) and setSelection($.txt.value.length, 0) are work for me . I used the bellow Test case. Tested with: Titanium Studio, build: 2.1.2.201208301612 Titanium SDK version: 3.2.0 Tested on Device: Samsung galaxy s duos Android version: 4.0.4 And Android 4.2.2 emulator , Android 2.3.3 emulator ,
Additional test: Xoom tablet running 4.1.2 The code has to be entered (with params reversed) as shown in my sample so that text is selected when you tap the field. Note that my test case used Alloy, not classic, and used the focus event not click.
I tried to reproduce the issue using an alloy app on android 4.1.2, 4.2.2 & 4.4.2 android devices & I could see the text is selected on focus in both cases when I used "$.txt.setSelection($.txt.value.length,0);" & $.txt.setSelection(0,$.txt.value.length);". I ran it on an iOS simulator too & it showed me the same results as android. Environment: Appc Studio : 3.2.3.201404162038 Ti SDK : 3.2.3.v20140417114627 Mac OSX : 10.8.5 Alloy : 1.3.1 CLI - 3.2.3-beta2
I can no longer reproduce the original issue. I tested on my Xoom tablet (specs above) and in the Genymotion emulator (Galaxy Nexus 4.2.2). You can close the ticket.
Based on the comments and feedback from Ingo, marking as invalid and closing.