{ "id": "134566", "key": "AC-1293", "fields": { "issuetype": { "id": "1", "description": "A problem which impairs or prevents the functions of the product.", "name": "Bug", "subtask": false }, "project": { "id": "12217", "key": "AC", "name": "Appcelerator - INBOX", "projectCategory": { "id": "10000", "description": "", "name": "Customer Service" } }, "resolution": { "id": "5", "description": "All attempts at reproducing this issue failed, or not enough information was available to reproduce the issue. Reading the code produces no clues as to why this behavior would occur. If more information appears later, please reopen the issue.", "name": "Cannot Reproduce" }, "resolutiondate": "2015-09-15T04:01:02.000+0000", "created": "2014-08-12T13:19:17.000+0000", "labels": [ "TCSupportTriage", "TextField", "change", "handler" ], "versions": [], "issuelinks": [], "assignee": { "name": "shossain", "key": "shossain", "displayName": "Shak Hossain", "active": false, "timeZone": "America/Los_Angeles" }, "updated": "2016-03-08T07:37:41.000+0000", "status": { "description": "A resolution has been taken, and it is awaiting verification by reporter. From here issues are either reopened, or are closed.", "name": "Resolved", "id": "5", "statusCategory": { "id": 3, "key": "done", "colorName": "green", "name": "Done" } }, "components": [ { "id": "14548", "name": "Titanium SDK & CLI", "description": "Please enter tickets related to the MobileSDK here." } ], "description": "h3. Steps to Reproduce\r\nCreate a new Classic project\r\nPase the code from the attached file\r\nRun the App on IOS\r\nRun the App on Android device/emulator\r\nWrite a combination of numbers and letters in the field\r\n\r\nh3. Actual Result\r\nOn IOS the change event is called and if invalid input the old value is set on the field the cursor is placed where it was before the event was called\r\nOn Android the change event is called and if invalid input the old value is set on the field but now the cursor is placed infront of the text. \r\n\r\nh3. Expected Result\r\nThe cursor should not be repositioned\r\n\r\nOn android it is virtually impossible to write a change handler to validate the contents of a TextField since the cursor is repositioned in front of the text if text is changed in the handler.", "attachment": [ { "id": "50414", "filename": "app.js", "author": { "name": "thomas.neerup@eg.dk", "key": "thomas.neerup@eg.dk", "displayName": "Thomas Neerup", "active": true, "timeZone": "Europe/Copenhagen" }, "created": "2014-08-12T13:19:19.000+0000", "size": 1914, "mimeType": "application/javascript" } ], "flagged": false, "summary": "Change event on TextField behaves badly on Android", "creator": { "name": "thomas.neerup@eg.dk", "key": "thomas.neerup@eg.dk", "displayName": "Thomas Neerup", "active": true, "timeZone": "Europe/Copenhagen" }, "subtasks": [], "reporter": { "name": "thomas.neerup@eg.dk", "key": "thomas.neerup@eg.dk", "displayName": "Thomas Neerup", "active": true, "timeZone": "Europe/Copenhagen" }, "environment": "SDK 3.3.0", "comment": { "comments": [ { "id": "318981", "author": { "name": "ahossain", "key": "ahossain", "displayName": "Amimul Hossain", "active": false, "timeZone": "Asia/Dhaka" }, "body": "Hello, We have tested the issue with the code sample provided, and observed the same problem. In android for a wrong value input, the cursor moved back to the initial starting position.\r\n\r\nTESTING ENVIRONMENT\r\n\r\nCLI version 3.3.0, \r\nTitanium SDK version 3.3.0.GA\r\nAndroid and iOS Simulator \r\n\r\nWorkaround \r\n\r\nWe have tested this code that limits the user to input digits only. It's working fine for both android and iOS.\r\n\r\nCODE SAMPLE\r\n\r\n{code:app.js}\r\n\r\n\r\n\r\nvar win = Ti.UI.createWindow({\r\n\tfullscreen : true,\r\n\texitOnClose : true,\r\n\tbackgroundColor : 'red'\r\n});\r\n\r\nvar txtInput = Titanium.UI.createTextField({\r\n color: '#336699',\r\n top: 10, left: 10,\r\n width: 250, height: 60,\r\n changeFlag: true //custom property\r\n});\r\ntxtInput.addEventListener('change',function(e){\r\n //check if first trigger of change event -> input of user\r\n if (e.source.changeFlag){\r\n //get user's input and store in temp variable\r\n var temp = e.source.value;\r\n //remove all non-digit characters in user's input\r\n temp = temp.replace(/[^0-9]/g,\"\");\r\n e.source.value = temp; //this will fire a second change event\r\n //get the new length of the value of the textfield object\r\n var len = e.source.value.length;\r\n //set the cursor position after the last character of the value of the textfield object\r\n e.source.setSelection(len,len);\r\n e.source.flag = false;\r\n }else{\r\n //the second firing of the change event do nothing\r\n e.source.flag = true;\r\n }\r\n});\r\n\r\nwin.add(txtInput);\r\nwin.open();\r\n\r\n{code}\r\n\r\nThanks.", "updateAuthor": { "name": "mpmiranda", "key": "mpmiranda", "displayName": "Mauro Parra-Miranda", "active": true, "timeZone": "America/Mexico_City" }, "created": "2014-08-16T08:17:23.000+0000", "updated": "2014-09-02T06:05:47.000+0000" }, { "id": "321283", "author": { "name": "mpmiranda", "key": "mpmiranda", "displayName": "Mauro Parra-Miranda", "active": true, "timeZone": "America/Mexico_City" }, "body": "Hello [~thomas.neerup@eg.dk]! \r\n\r\nCan you please take a look into the previous workaround and let me know if that solves the issue. \r\n\r\nBest Regards!", "updateAuthor": { "name": "mpmiranda", "key": "mpmiranda", "displayName": "Mauro Parra-Miranda", "active": true, "timeZone": "America/Mexico_City" }, "created": "2014-09-02T06:06:45.000+0000", "updated": "2014-09-02T06:06:45.000+0000" }, { "id": "327257", "author": { "name": "thomas.neerup@eg.dk", "key": "thomas.neerup@eg.dk", "displayName": "Thomas Neerup", "active": true, "timeZone": "Europe/Copenhagen" }, "body": "No the previous workaround does not solve the issue.. \r\nThe code does not work... ", "updateAuthor": { "name": "thomas.neerup@eg.dk", "key": "thomas.neerup@eg.dk", "displayName": "Thomas Neerup", "active": true, "timeZone": "Europe/Copenhagen" }, "created": "2014-10-08T07:02:49.000+0000", "updated": "2014-10-08T07:02:49.000+0000" }, { "id": "338330", "author": { "name": "thomas.neerup@eg.dk", "key": "thomas.neerup@eg.dk", "displayName": "Thomas Neerup", "active": true, "timeZone": "Europe/Copenhagen" }, "body": "Any news on this one?\r\nOr any thoughts on how to limit numeric input on a TextField on android?", "updateAuthor": { "name": "thomas.neerup@eg.dk", "key": "thomas.neerup@eg.dk", "displayName": "Thomas Neerup", "active": true, "timeZone": "Europe/Copenhagen" }, "created": "2015-01-08T08:57:47.000+0000", "updated": "2015-01-08T08:57:47.000+0000" }, { "id": "348761", "author": { "name": "ahossain", "key": "ahossain", "displayName": "Amimul Hossain", "active": false, "timeZone": "Asia/Dhaka" }, "body": "I have tested this with SDK latest version. The workaround proposed works for me. I am going to mark this ticket as resolved. If you still get the error, please reopen this ticket.\r\n", "updateAuthor": { "name": "shossain", "key": "shossain", "displayName": "Shak Hossain", "active": false, "timeZone": "America/Los_Angeles" }, "created": "2015-04-07T09:51:23.000+0000", "updated": "2015-09-15T04:00:55.000+0000" }, { "id": "363909", "author": { "name": "thomas.neerup@eg.dk", "key": "thomas.neerup@eg.dk", "displayName": "Thomas Neerup", "active": true, "timeZone": "Europe/Copenhagen" }, "body": "OMG. How can this be closed and marked as Resolved. When the bug still exist.", "updateAuthor": { "name": "thomas.neerup@eg.dk", "key": "thomas.neerup@eg.dk", "displayName": "Thomas Neerup", "active": true, "timeZone": "Europe/Copenhagen" }, "created": "2015-09-15T07:24:33.000+0000", "updated": "2015-09-15T07:24:33.000+0000" } ], "maxResults": 7, "total": 7, "startAt": 0 } } }