{ "id": "121575", "key": "TIMOB-16176", "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": [], "resolution": null, "resolutiondate": null, "created": "2013-10-24T07:05:58.000+0000", "priority": { "name": "Low", "id": "4" }, "labels": [ "android", "change", "textfield" ], "versions": [ { "id": "14982", "description": "Release 3.2.0", "name": "Release 3.2.0", "archived": false, "released": true, "releaseDate": "2013-12-19" } ], "issuelinks": [], "assignee": { "name": "emerriman", "key": "emerriman", "displayName": "Eric Merriman ", "active": true, "timeZone": "America/Los_Angeles" }, "updated": "2019-04-30T14:16:00.000+0000", "status": { "description": "This issue was once resolved, but the resolution was deemed incorrect. From here issues are either marked assigned or resolved.", "name": "Reopened", "id": "4", "statusCategory": { "id": 2, "key": "new", "colorName": "blue-gray", "name": "To Do" } }, "components": [ { "id": "10202", "name": "Android", "description": "Android Platform" } ], "description": "changing the value of the text field in change handler is not possible. \r\ntextField.addEventListener(\"change\", function(){ \r\ntextField.value = textField.value.replace(/some regex/,\"\");\r\n} \r\nthis code is crushing whole device. I have to restart the device. ", "attachment": [], "flagged": false, "summary": "Android: Cannot change TextField value in change event handler", "creator": { "name": "natashapp", "key": "natashapp", "displayName": "Natasha Pecanova", "active": true, "timeZone": "America/Los_Angeles" }, "subtasks": [], "reporter": { "name": "natashapp", "key": "natashapp", "displayName": "Natasha Pecanova", "active": true, "timeZone": "America/Los_Angeles" }, "environment": "Titanium built 3.1.2 SDK 3.1.3 GA Android device Acer Pad ", "comment": { "comments": [ { "id": "276927", "author": { "name": "morahman", "key": "morahman", "displayName": "Motiur Rahman", "active": true, "timeZone": "Asia/Dhaka" }, "body": "Hi\r\n\r\nI tested this *change* event using the sample below. Can you please give my code a try to see if this solves your issue. If not, please post your test case so that we can help.\r\n\r\n*Test Environment*\r\nTitanium SDK 3.1.2 & SDK 3.1.3 GA\r\nandroid 4.2.2 Real device. \r\n\r\n*Test Case*\r\n{code}\r\nvar win = Ti.UI.createWindow({\r\nbackgroundColor:'#fff'\r\n});\r\n\r\n// Create a TextField.\r\nvar tf1 = Titanium.UI.createTextField({\r\n\tcolor : '#336699',\r\n\theight : 35,\r\n\ttop : 10,\r\n\tleft : 10,\r\n\twidth : 250,\r\n\tborderStyle : Titanium.UI.INPUT_BORDERSTYLE_ROUNDED\r\n});\r\n\r\nwin.add(tf1);\r\n\r\nvar l = Titanium.UI.createLabel({\r\n\ttop : 50,\r\n\tleft : 10,\r\n\twidth : 300,\r\n\theight : 'auto',\r\n\tcolor : '#777',\r\n\tfont : {\r\n\t\tfontSize : 13\r\n\t},\r\n\ttext : 'do something like click a button...'\r\n});\r\nwin.add(l);\r\ntf1.addEventListener('change', function(e) {\r\n\t//l.text = 'change received, event val = ' + e.value + '\\nfield val = ' + tf1.value;\r\n\tl.text = 'change received, field val = ' + tf1.value;\r\n});\r\nwin.open();\r\n\r\n{code}\r\n\r\n ", "updateAuthor": { "name": "shossain", "key": "shossain", "displayName": "Shak Hossain", "active": false, "timeZone": "America/Los_Angeles" }, "created": "2013-10-27T15:03:41.000+0000", "updated": "2014-01-01T02:56:04.000+0000" }, { "id": "277082", "author": { "name": "mpmiranda", "key": "mpmiranda", "displayName": "Mauro Parra-Miranda", "active": true, "timeZone": "America/Mexico_City" }, "body": "Hello,\r\n\r\nplease provide a full test case. \r\n\r\nBest,\r\n\r\nMauro ", "updateAuthor": { "name": "mpmiranda", "key": "mpmiranda", "displayName": "Mauro Parra-Miranda", "active": true, "timeZone": "America/Mexico_City" }, "created": "2013-10-29T00:38:51.000+0000", "updated": "2013-10-29T00:38:51.000+0000" }, { "id": "277124", "author": { "name": "natashapp", "key": "natashapp", "displayName": "Natasha Pecanova", "active": true, "timeZone": "America/Los_Angeles" }, "body": "add one text field \nadd change listener\n\non IOS you will not have a problem \non Android it recursively calls change handler function\n\ntextField.addEventListener(\"change\", function(){ textField.value = textField.value.replace(/,/g, '.'); } \n\ntesting if there is a need of changing the value should solve the problem. \n", "updateAuthor": { "name": "natashapp", "key": "natashapp", "displayName": "Natasha Pecanova", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2013-10-29T10:41:31.000+0000", "updated": "2013-10-29T10:41:31.000+0000" }, { "id": "277201", "author": { "name": "mpmiranda", "key": "mpmiranda", "displayName": "Mauro Parra-Miranda", "active": true, "timeZone": "America/Mexico_City" }, "body": "Natasha, \na full test case is the entire code, an app.js that reproduces the issue. \n\nBest,\n\nMauro ", "updateAuthor": { "name": "mpmiranda", "key": "mpmiranda", "displayName": "Mauro Parra-Miranda", "active": true, "timeZone": "America/Mexico_City" }, "created": "2013-10-29T18:31:30.000+0000", "updated": "2013-10-29T18:31:30.000+0000" }, { "id": "287917", "author": { "name": "ragrawal", "key": "ragrawal", "displayName": "Ritu Agrawal", "active": true, "timeZone": "America/Los_Angeles" }, "body": "Reopening this ticket as we can reproduce this issue on Android platform. I had to shut down my phone as the application went into infinite recursion.", "updateAuthor": { "name": "ragrawal", "key": "ragrawal", "displayName": "Ritu Agrawal", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2014-01-12T19:58:31.000+0000", "updated": "2014-01-12T19:58:31.000+0000" }, { "id": "329732", "author": { "name": "etruta", "key": "etruta", "displayName": "Eduardo Silva", "active": true, "timeZone": "America/Sao_Paulo" }, "body": "This bug also happens with version 3.4.0.GA.", "updateAuthor": { "name": "etruta", "key": "etruta", "displayName": "Eduardo Silva", "active": true, "timeZone": "America/Sao_Paulo" }, "created": "2014-10-28T12:08:57.000+0000", "updated": "2014-10-28T12:08:57.000+0000" }, { "id": "343436", "author": { "name": "Daniel HJ", "key": "daniel hj", "displayName": "Daniel Hernández Jara", "active": true, "timeZone": "America/Los_Angeles" }, "body": "Same problem in version 3.5.0... In native implementations are a lot of solutions... one of this solutions is edit theme for the editText and set the attribute \"android:focusableInTouchMode=true\" i don't know if this works... but i'll try and commend here.", "updateAuthor": { "name": "Daniel HJ", "key": "daniel hj", "displayName": "Daniel Hernández Jara", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2015-02-14T14:51:06.000+0000", "updated": "2015-02-14T15:14:33.000+0000" }, { "id": "343437", "author": { "name": "Daniel HJ", "key": "daniel hj", "displayName": "Daniel Hernández Jara", "active": true, "timeZone": "America/Los_Angeles" }, "body": "i came with a patch solution:\r\n{code:borderStyle=solid}\r\n...\r\n\r\nvar textField = Ti.UI.createTextField();\r\n\r\nfunction myFunction() {\r\n // Remove listener to avoid infinite loop.\r\n if (OS_ANDROID){\r\n\t textField.removeEventListener('change', myFunction);\r\n }\r\n \r\n\r\n //Then use the normal replace in IOS and \"The Solution\" in Android\r\n //RegEx accept number values with the format x*,xx\r\n if (OS_IOS) {\r\n\t textField.value = textField.value.replace(/[^\\d,]|(,{2,})|(,\\d*,)|(,\\d{3,})|^(?!\\d),/, \"\");\r\n } else {\r\n\t changeValue(textField.value.replace(/[^\\d,]|(,{2,})|(,\\d*,)|(,\\d{3,})|^(?!\\d),/, \"\"));\r\n }\r\n}\r\n\r\nfunction changeValue(value) {\r\n //Do the replace.\r\n textField.value = value;\r\n \r\n //Put the cursor in the end of the value in the textfield\r\n textField.setSelection(textField.value.length, textField.value.length);\t\r\n \r\n //Add the event 'change'.\r\n setTimeout(function() {\r\n textField.addEventListener('change', myFunction);\r\n }, 100);\r\n}\r\n\r\ntextField.addEventListener('change', myFunction);\r\n{code}\r\n\r\n\r\nI hope this will help mean while you guys.\r\n\r\n", "updateAuthor": { "name": "Daniel HJ", "key": "daniel hj", "displayName": "Daniel Hernández Jara", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2015-02-14T17:09:20.000+0000", "updated": "2015-02-14T17:09:20.000+0000" }, { "id": "390360", "author": { "name": "dxgx82", "key": "dxgx82", "displayName": "Darius G", "active": true, "timeZone": "America/Los_Angeles" }, "body": "Just informing that problem exists: 5.3.1GA\r\nAndroid: 6.0.1 real device.\r\nonchange value changing gives infinity loop\r\n\r\nThanks *Daniel Hernández Jara* your workaround works!", "updateAuthor": { "name": "dxgx82", "key": "dxgx82", "displayName": "Darius G", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2016-07-11T19:55:59.000+0000", "updated": "2016-07-11T19:59:35.000+0000" }, { "id": "417019", "author": { "name": "bgarcia", "key": "bgarcia", "displayName": "Brian García", "active": true, "timeZone": "America/Los_Angeles" }, "body": "Still happens with the latest SDK", "updateAuthor": { "name": "bgarcia", "key": "bgarcia", "displayName": "Brian García", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2017-04-07T11:49:08.000+0000", "updated": "2017-04-07T11:49:08.000+0000" }, { "id": "432479", "author": { "name": "clement", "key": "clement", "displayName": "Clément Blanco", "active": true, "timeZone": "America/Los_Angeles" }, "body": "Not answering the problem, just a bit more elegant way to find your way around it using underscore.js:\r\n\r\n{code}\r\ntextField.addEventListener(\"change\", _.debounce(function(e) {\r\n e.source.value = e.value = doSomethingToMyValue(e.value);\r\n e.source.setSelection(e.value.length, e.value.length);\r\n}, 100, true));\r\n{code}\r\n\r\nThe downside being not being able to type text rapidly and having to wait about a second before typing the cursor is in place again...", "updateAuthor": { "name": "clement", "key": "clement", "displayName": "Clément Blanco", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2017-12-21T15:14:53.000+0000", "updated": "2017-12-21T16:11:30.000+0000" }, { "id": "433979", "author": { "name": "jjoseph", "key": "jjoseph", "displayName": "Johnson Joseph", "active": true, "timeZone": "America/Los_Angeles" }, "body": "This problem exists in Android in the Titanium 7.0.1GA", "updateAuthor": { "name": "jjoseph", "key": "jjoseph", "displayName": "Johnson Joseph", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2018-02-02T18:52:19.000+0000", "updated": "2018-02-02T18:52:19.000+0000" }, { "id": "434042", "author": { "name": "clement", "key": "clement", "displayName": "Clément Blanco", "active": true, "timeZone": "America/Los_Angeles" }, "body": "Can we get someone to look at this please?", "updateAuthor": { "name": "clement", "key": "clement", "displayName": "Clément Blanco", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2018-02-05T09:16:43.000+0000", "updated": "2018-02-05T09:16:43.000+0000" }, { "id": "448075", "author": { "name": "jkneen", "key": "jkneen", "displayName": "Jason Kneen", "active": false, "timeZone": "Africa/Ceuta" }, "body": "This is still an issue in 8.0.0.GA", "updateAuthor": { "name": "jkneen", "key": "jkneen", "displayName": "Jason Kneen", "active": false, "timeZone": "Africa/Ceuta" }, "created": "2019-04-30T14:15:47.000+0000", "updated": "2019-04-30T14:15:47.000+0000" } ], "maxResults": 15, "total": 15, "startAt": 0 } } }