{ "id": "124855", "key": "TIMOB-16198", "fields": { "issuetype": { "id": "1", "description": "A problem which impairs or prevents the functions of the product.", "name": "Bug", "subtask": false }, "project": { "id": "10153", "key": "TIMOB", "name": "Titanium SDK/CLI", "projectCategory": { "id": "10100", "description": "Titanium and related SDKs used in application development", "name": "Client" } }, "fixVersions": [ { "id": "15422", "description": "Release 3.3.0", "name": "Release 3.3.0", "archived": false, "released": true, "releaseDate": "2014-07-16" } ], "resolution": { "id": "7", "description": "", "name": "Invalid" }, "resolutiondate": "2015-04-13T16:19:34.000+0000", "created": "2014-01-16T02:12:13.000+0000", "priority": { "name": "Medium", "id": "3" }, "labels": [ "triage" ], "versions": [ { "id": "14982", "description": "Release 3.2.0", "name": "Release 3.2.0", "archived": false, "released": true, "releaseDate": "2013-12-19" } ], "issuelinks": [], "assignee": { "name": "bijuexalture", "key": "bijuexalture", "displayName": "Biju pm", "active": true, "timeZone": "Asia/Kolkata" }, "updated": "2015-04-13T16:19:38.000+0000", "status": { "description": "The issue is considered finished, the resolution is correct. Issues which are closed can be reopened.", "name": "Closed", "id": "6", "statusCategory": { "id": 3, "key": "done", "colorName": "green", "name": "Done" } }, "components": [ { "id": "10202", "name": "Android", "description": "Android Platform" } ], "description": "h2. Expected behavior\r\n\r\nPer 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)\r\n\r\nhttp://docs.appcelerator.com/titanium/latest/#!/api/Titanium.UI.TextField-method-setSelection\r\n\r\nh2. Actual behavior\r\n\r\nOn Android, it appears that those parameters are reversed. The following code will select all the text in the text field on iOS & Android\r\n\r\n{code}\r\n$.txt.addEventListener('focus', function(e) {\r\n if(OS_IOS) {\r\n $.txt.setSelection(0,$.txt.value.length);\r\n } else {\r\n // params are backward on Android\r\n $.txt.setSelection($.txt.value.length, 0);\r\n }\r\n});\r\n{code}", "attachment": [], "flagged": false, "summary": "Android: setSelection() params reversed", "creator": { "name": "skypanther", "key": "skypanther", "displayName": "Tim Poulsen", "active": true, "timeZone": "America/New_York" }, "subtasks": [], "reporter": { "name": "skypanther", "key": "skypanther", "displayName": "Tim Poulsen", "active": true, "timeZone": "America/New_York" }, "environment": "Tested with 3.2.0.GA, Alloy 1.3.0, iOS 7 simulator, and Genymotion emulator running Android 4.3", "comment": { "comments": [ { "id": "288420", "author": { "name": "bijuexalture", "key": "bijuexalture", "displayName": "Biju pm", "active": true, "timeZone": "Asia/Kolkata" }, "body": "Both setSelection(0, $.txt.value.length) and setSelection($.txt.value.length, 0) are work for me . I used the bellow Test case.\n\nTested with: \nTitanium Studio, build: 2.1.2.201208301612\nTitanium SDK version: 3.2.0\nTested on\nDevice: Samsung galaxy s duos Android version: 4.0.4\nAnd\nAndroid 4.2.2 emulator , Android 2.3.3 emulator , \n\n{code}\nTitanium.UI.setBackgroundColor('#000');\n \n// create base UI tab and root window\nvar window = Titanium.UI.createWindow({ \n title:'Select Text',\n backgroundColor:'#fff'\n});\n \nvar textfield = Titanium.UI.createTextField({\n color:'#336699',\n height:35,\n width:200,\n top:10,\n left:10,\n});\n \nvar button1 = Titanium.UI.createButton({\n title:'Select',\n top:50,\n left:10\n});\n \nbutton1.addEventListener('click', function() {\n textfield.setSelection(0, textfield.value.length);\n});\n \n \nwindow.add(textfield);\nwindow.add(button1);\nwindow.open();\n{code}", "updateAuthor": { "name": "bijuexalture", "key": "bijuexalture", "displayName": "Biju pm", "active": true, "timeZone": "Asia/Kolkata" }, "created": "2014-01-16T06:44:07.000+0000", "updated": "2014-01-16T06:44:07.000+0000" }, { "id": "288442", "author": { "name": "skypanther", "key": "skypanther", "displayName": "Tim Poulsen", "active": true, "timeZone": "America/New_York" }, "body": "Additional test: Xoom tablet running 4.1.2\n\nThe code has to be entered (with params reversed) as shown in my sample so that text is selected when you tap the field.\n\nNote that my test case used Alloy, not classic, and used the focus event not click.", "updateAuthor": { "name": "skypanther", "key": "skypanther", "displayName": "Tim Poulsen", "active": true, "timeZone": "America/New_York" }, "created": "2014-01-16T14:40:51.000+0000", "updated": "2014-01-16T14:40:51.000+0000" }, { "id": "302051", "author": { "name": "lchoudhary", "key": "lchoudhary", "displayName": "Lokesh Choudhary", "active": true, "timeZone": "America/Los_Angeles" }, "body": "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.\r\n\r\nEnvironment:\r\nAppc Studio : 3.2.3.201404162038\r\nTi SDK : 3.2.3.v20140417114627\r\nMac OSX : 10.8.5\r\nAlloy : 1.3.1\t\r\nCLI - 3.2.3-beta2", "updateAuthor": { "name": "lchoudhary", "key": "lchoudhary", "displayName": "Lokesh Choudhary", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2014-04-22T16:56:21.000+0000", "updated": "2014-04-22T16:56:21.000+0000" }, { "id": "302062", "author": { "name": "skypanther", "key": "skypanther", "displayName": "Tim Poulsen", "active": true, "timeZone": "America/New_York" }, "body": "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.", "updateAuthor": { "name": "skypanther", "key": "skypanther", "displayName": "Tim Poulsen", "active": true, "timeZone": "America/New_York" }, "created": "2014-04-22T17:59:16.000+0000", "updated": "2014-04-22T17:59:16.000+0000" }, { "id": "302067", "author": { "name": "emerriman", "key": "emerriman", "displayName": "Eric Merriman ", "active": true, "timeZone": "America/Los_Angeles" }, "body": "Based on the comments and feedback from Ingo, marking as invalid and closing.", "updateAuthor": { "name": "emerriman", "key": "emerriman", "displayName": "Eric Merriman ", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2014-04-22T18:22:10.000+0000", "updated": "2014-04-22T18:22:10.000+0000" } ], "maxResults": 5, "total": 5, "startAt": 0 } } }