{ "id": "151448", "key": "TIMOB-19639", "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": "17706", "name": "Release 5.4.0", "archived": false, "released": true, "releaseDate": "2016-08-11" } ], "resolution": { "id": "1", "description": "A fix for this issue is checked into the tree and tested.", "name": "Fixed" }, "resolutiondate": "2016-04-22T16:31:01.000+0000", "created": "2015-09-24T08:16:55.000+0000", "priority": { "name": "High", "id": "2" }, "labels": [ "android", "selection", "textfield" ], "versions": [], "issuelinks": [], "assignee": { "name": "hknoechel", "key": "hansknoechel", "displayName": "Hans Knöchel", "active": true, "timeZone": "Europe/Berlin" }, "updated": "2016-06-28T23:14:18.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": "When trying to select the whole text in a TextField I use the setSelection function:\r\n\r\n{code:java}\r\nfunction selectText(e){\r\n $.tf_1.setSelection(0,$.tf_1.value.length)\r\n}\r\n\r\n$.btn.addEventListener(\"click\",selectText)\r\n$.index.open();\r\n{code}\r\n\r\n\r\n{code:java}\r\n\r\n\t\r\n\t\t\r\n\t\t\r\n\t\r\n\r\n{code}\r\n\r\n\r\n{noformat}\r\n\"TextField\": {\r\n right:50,\r\n left:50,\r\n color:\"black\"\r\n}\r\n\".container\": {\r\n layout:\"vertical\",\r\n backgroundColor:\"white\"\r\n}\r\n{noformat}\r\n\r\nIt'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. \r\nFrom the function call (0, length) I expect to start from 0 and select the whole text in one go\r\n\r\nAndroid 5 (Nexus 4)\r\nSDK 5.0.0.GA\r\n\r\n_Workaround:_\r\nuse \r\n{code:java}\r\nfunction selectText(e){\r\n $.tf_1.setSelection(0,$.tf_1.value.length)\r\n _.delay(function(){\r\n $.tf_1.setSelection(0,$.tf_1.value.length)\r\n },200);\r\n}\r\n{code}", "attachment": [], "flagged": false, "summary": "Android: TextField setSelection(0,end) has to be called twice to select text", "creator": { "name": "michael", "key": "michael", "displayName": "Michael Gangolf", "active": true, "timeZone": "Europe/Berlin" }, "subtasks": [], "reporter": { "name": "michael", "key": "michael", "displayName": "Michael Gangolf", "active": true, "timeZone": "Europe/Berlin" }, "environment": "SDK 5.0.0.GA\r\nAndroid 5", "closedSprints": [ { "id": 618, "state": "closed", "name": "2016 Sprint 08 SDK", "startDate": "2016-04-09T00:30:18.262Z", "endDate": "2016-04-23T00:30:00.000Z", "completeDate": "2016-04-25T02:38:28.511Z", "originBoardId": 114 } ], "comment": { "comments": [ { "id": "381345", "author": { "name": "michael", "key": "michael", "displayName": "Michael Gangolf", "active": true, "timeZone": "Europe/Berlin" }, "body": "PR: https://github.com/appcelerator/titanium_mobile/pull/7905\r\n\r\nBug caused by IME (input method editor), see: http://stackoverflow.com/a/35527348/5193915", "updateAuthor": { "name": "michael", "key": "michael", "displayName": "Michael Gangolf", "active": true, "timeZone": "Europe/Berlin" }, "created": "2016-04-02T11:20:57.000+0000", "updated": "2016-04-02T11:20:57.000+0000" }, { "id": "381349", "author": { "name": "hknoechel", "key": "hansknoechel", "displayName": "Hans Knöchel", "active": true, "timeZone": "Europe/Berlin" }, "body": "[~michael] The PR looks great! Can you provide a demo code that can be ran without Alloy? I can create one if it exceeds your available time, just let me know.", "updateAuthor": { "name": "hknoechel", "key": "hansknoechel", "displayName": "Hans Knöchel", "active": true, "timeZone": "Europe/Berlin" }, "created": "2016-04-02T12:36:40.000+0000", "updated": "2016-04-02T12:36:40.000+0000" }, { "id": "381353", "author": { "name": "michael", "key": "michael", "displayName": "Michael Gangolf", "active": true, "timeZone": "Europe/Berlin" }, "body": "no problem:\r\n\r\n{code:java}\r\nvar win = $.UI.create(\"Window\",{\r\n layout:\"vertical\",\r\n backgroundColor:\"#fff\"\r\n});\r\n\r\nvar tf = $.UI.create(\"TextField\",{\r\n value:\"12345678\"\r\n});\r\n\r\nfunction selectText(e){\r\n tf.setSelection(0,tf.value.length)\r\n}\r\n\r\nfunction selectText2(e){\r\n tf.setSelection(2,5)\r\n}\r\n\r\nvar btn = $.UI.create(\"Button\",{\r\n title:\"Select all\"\r\n});\r\n\r\nvar btn2 = $.UI.create(\"Button\",{\r\n title:\"Select 2-5\"\r\n});\r\n\r\nwin.add(tf);\r\nwin.add(btn);\r\nwin.add(btn2);\r\n\r\nbtn.addEventListener(\"click\",selectText)\r\nbtn2.addEventListener(\"click\",selectText2)\r\n\r\n\r\nwin.open();\r\n{code}\r\n\r\n*Steps to reproduce*\r\n* Click inside the textview so the cursor is not in front\r\n* Click a button to set the selection\r\n\r\n*without the patch*\r\ncursor moves to the beginnen, no selection. You have to press the button again (it will change the cursor from \"selection cursor\" to the normal one)\r\n\r\n*with the patch*\r\ntext gets selected ", "updateAuthor": { "name": "michael", "key": "michael", "displayName": "Michael Gangolf", "active": true, "timeZone": "Europe/Berlin" }, "created": "2016-04-02T13:44:38.000+0000", "updated": "2016-04-02T13:44:38.000+0000" }, { "id": "383681", "author": { "name": "hknoechel", "key": "hansknoechel", "displayName": "Hans Knöchel", "active": true, "timeZone": "Europe/Berlin" }, "body": "Approved! Thank you [~michael], great work!", "updateAuthor": { "name": "hknoechel", "key": "hansknoechel", "displayName": "Hans Knöchel", "active": true, "timeZone": "Europe/Berlin" }, "created": "2016-04-22T16:31:28.000+0000", "updated": "2016-04-22T16:31:28.000+0000" }, { "id": "389324", "author": { "name": "lchoudhary", "key": "lchoudhary", "displayName": "Lokesh Choudhary", "active": true, "timeZone": "America/Los_Angeles" }, "body": "Verified the fix.\r\n\r\nClosing.\r\n\r\nEnvironment:\r\nAppc Studio : 4.7.0.201606150733\r\nTi SDK : 5.4.0.v20160617074028\r\nTi CLI : 5.0.9\r\nAlloy : 1.9.0\r\nMAC El Capitan : 10.11.4\r\nAppc NPM : 4.2.7-2\r\nAppc CLI : 5.4.0-20\r\nNode: 4.4.4\r\nNexus 6 - Android 6.0.1", "updateAuthor": { "name": "lchoudhary", "key": "lchoudhary", "displayName": "Lokesh Choudhary", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2016-06-28T23:14:02.000+0000", "updated": "2016-06-28T23:14:02.000+0000" } ], "maxResults": 6, "total": 6, "startAt": 0 } } }