{ "id": "139594", "key": "TIMOB-18037", "fields": { "issuetype": { "id": "4", "description": "An improvement or enhancement to an existing feature or task.", "name": "Improvement", "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": "2014-11-12T13:50:18.000+0000", "priority": { "name": "None", "id": "6" }, "labels": [ "TCSupport", "attributedString", "label", "links", "textarea", "textfield" ], "versions": [ { "id": "16676", "description": "Release 3.4.1", "name": "Release 3.4.1", "archived": false, "released": true, "releaseDate": "2014-11-14" } ], "issuelinks": [], "assignee": null, "updated": "2018-02-28T19:54:54.000+0000", "status": { "description": "The issue is open and ready for the assignee to start work on it.", "name": "Open", "id": "1", "statusCategory": { "id": 2, "key": "new", "colorName": "blue-gray", "name": "To Do" } }, "components": [ { "id": "10206", "name": "iOS", "description": "iOS Platform" } ], "description": "Only for TextArea we have a property [handleLinks|http://docs.appcelerator.com/titanium/latest/#!/api/Titanium.UI.TextArea-property-handleLinks] which if set to `true` fires the `link` event for a single-tap on a link in an Attributed String.\r\n\r\n- For Label only a long-press can trigger this event, making a poor UX.\r\n- For TextField there's no such event at all, making the attribute type useless.\r\n- For TextArea the link has a different color, no underline and a tap will always open the URL in Safari before firing the {{link}} event, allowing no custom actions. Also, the documentation does not inform you about the need for {{editable}} to be set to {{false}} to capture link events.\r\n\r\nh1. Test case\r\n\r\n{code}\r\nvar win = Titanium.UI.createWindow({\r\n backgroundColor: '#ddd',\r\n});\r\n\r\nvar label = Ti.UI.createLabel({\r\n top: 100,\r\n attributedString: Ti.UI.iOS.createAttributedString({\r\n text: 'Appcelerator as Label (long press)',\r\n attributes: [{\r\n type: Ti.UI.iOS.ATTRIBUTE_LINK,\r\n value: 'http://www.appcelerator.com',\r\n range: [0, 12]\r\n }]\r\n })\r\n});\r\n\r\n// will only fire on long press\r\nlabel.addEventListener('link', function(e) {\r\n alert(e.url);\r\n});\r\n\r\nvar textField = Ti.UI.createTextField({\r\n top: 200,\r\n editable: false,\r\n attributedString: Ti.UI.iOS.createAttributedString({\r\n text: 'Appcelerator as TextField (long press)',\r\n attributes: [{\r\n type: Ti.UI.iOS.ATTRIBUTE_LINK,\r\n value: 'http://www.appcelerator.com',\r\n range: [0, 12]\r\n }]\r\n })\r\n});\r\n\r\n// no such event available for TextField\r\ntextField.addEventListener('link', function(e) {\r\n alert(e.url);\r\n});\r\n\r\nvar textArea = Ti.UI.createTextArea({\r\n top: 300,\r\n handleLinks: true,\r\n editable: false,\r\n attributedString: Ti.UI.iOS.createAttributedString({\r\n text: 'Appcelerator as TextArea with handleLinks:true (single tap)',\r\n attributes: [{\r\n type: Ti.UI.iOS.ATTRIBUTE_LINK,\r\n value: 'http://www.appcelerator.com',\r\n range: [0, 12]\r\n }]\r\n })\r\n});\r\n\r\n// fires on single tap\r\ntextArea.addEventListener('link', function(e) {\r\n\r\n // has no effect, will always open URL in Safari and show alert when you come back\r\n e.cancelBubble = true;\r\n\r\n alert(e.url);\r\n});\r\n\r\nwin.add(label);\r\nwin.add(textField);\r\nwin.add(textArea);\r\n\r\nwin.open();\r\n{code}\r\n\r\nh1. Suggested changes:\r\n\r\n* Bring {{handleLinks}} to TextField and Label\r\n* Let {{handleLinks}} automatically set {{editable}} to {{false}}.\r\n* Use the same color and underlining of links in TextAreas as in TextFields and Labels.", "attachment": [ { "id": "52506", "filename": "iOS Simulator Screen Shot 12 Nov 2014 14.49.50.png", "author": { "name": "fokkezb", "key": "fokke", "displayName": "Fokke Zandbergen", "active": true, "timeZone": "Europe/Amsterdam" }, "created": "2014-11-12T13:50:18.000+0000", "size": 47034, "mimeType": "image/png" } ], "flagged": false, "summary": "Parity: Handing of links in Attributed Strings for Label, TextField and TextArea", "creator": { "name": "fokkezb", "key": "fokke", "displayName": "Fokke Zandbergen", "active": true, "timeZone": "Europe/Amsterdam" }, "subtasks": [], "reporter": { "name": "fokkezb", "key": "fokke", "displayName": "Fokke Zandbergen", "active": true, "timeZone": "Europe/Amsterdam" }, "environment": "3.4.1.RC", "comment": { "comments": [ { "id": "331816", "author": { "name": "yuchi", "key": "yuchi", "displayName": "Pier Paolo Ramon", "active": true, "timeZone": "Europe/Berlin" }, "body": "This is almost impossible to work around without doing (very) nasty stuff on the native side.\r\n\r\nInstant watch.", "updateAuthor": { "name": "yuchi", "key": "yuchi", "displayName": "Pier Paolo Ramon", "active": true, "timeZone": "Europe/Berlin" }, "created": "2014-11-12T15:17:07.000+0000", "updated": "2014-11-12T15:17:07.000+0000" } ], "maxResults": 1, "total": 1, "startAt": 0 } } }