{ "id": "132858", "key": "TIMOB-17409", "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": "2014-07-10T09:00:35.000+0000", "priority": { "name": "Medium", "id": "3" }, "labels": [ "TCSupport", "click", "rect", "unit" ], "versions": [ { "id": "15422", "description": "Release 3.3.0", "name": "Release 3.3.0", "archived": false, "released": true, "releaseDate": "2014-07-16" } ], "issuelinks": [], "assignee": null, "updated": "2018-02-28T20:04:21.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": "10202", "name": "Android", "description": "Android Platform" }, { "id": "10206", "name": "iOS", "description": "iOS Platform" } ], "description": "While making the [nl.fokkezb.color|https://github.com/fokkezb/nl.fokkezb.color] widget I noticed {{Ti.UI.View.rect}} and the {{x}} and {{y}} coordinate given in click (and other) events use different units.\r\n\r\nThe documentation of [rect|http://docs.appcelerator.com/titanium/latest/#!/api/Titanium.UI.View-property-rect] clearly states it always uses the system unit (px on Android, dp on iOS) while the click docs (http://docs.appcelerator.com/titanium/latest/#!/api/Titanium.UI.View-event-click) don't specify the unit.\r\n\r\nWhen you execute the following {{app.js}} without and with {{ti.ui.defaultunit}} set to both {{dp}} and {{px}} on both platforms and click in the bottom right corner of the screen you'll see {{rect}} does *not* use the system unit but rather the defaultunit. The event coordinates *do* always use the system unit. The results can be found under the code snippet.\r\n\r\nThe documentation should be fixed, but I'd also request for both to use the same units, be it system or default unit.\r\n\r\n{code}\r\nconsole.debug(Ti.App.Properties.getString('ti.ui.defaultunit'));\r\nvar win = Ti.UI.createWindow({backgroundColor:'white'});\r\nwin.addEventListener('postlayout', function(e) {\r\n console.debug('rect: ' + win.rect.width + ',' + win.rect.height);\r\n});\r\nwin.addEventListener('click', function(e) {\r\n console.debug('click: ' + e.x + ',' + e.y);\r\n});\r\nwin.open();\r\n{code}\r\n\r\nh2. iOS\r\n\r\n||ti.ui.defaultunit||rect||click||\r\n|(none)|dp|dp|\r\n|px|px|dp|\r\n|dp|dp|dp|\r\n\r\nh2. Android\r\n\r\n||ti.ui.defaultunit||rect||click||\r\n|(none)|px|px|\r\n|px|px|px|\r\n|dp|dp|px|", "attachment": [], "flagged": false, "summary": "Both Ti.UI.View.rect and event coordinates should use the (same) documented unit", "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": "SDK 3.3.0.RC", "comment": { "comments": [ { "id": "315936", "author": { "name": "mpmiranda", "key": "mpmiranda", "displayName": "Mauro Parra-Miranda", "active": true, "timeZone": "America/Mexico_City" }, "body": "Thanks for your report! The DOC team will discuss this and set the priority. ", "updateAuthor": { "name": "mpmiranda", "key": "mpmiranda", "displayName": "Mauro Parra-Miranda", "active": true, "timeZone": "America/Mexico_City" }, "created": "2014-07-28T03:20:51.000+0000", "updated": "2014-07-28T03:20:51.000+0000" }, { "id": "318737", "author": { "name": "ingo", "key": "ingo", "displayName": "Ingo Muschenetz", "active": true, "timeZone": "America/Los_Angeles" }, "body": "3.4.0 is moved forward, and 3.5.0 is taking its place in the calendar.", "updateAuthor": { "name": "ingo", "key": "ingo", "displayName": "Ingo Muschenetz", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2014-08-14T21:31:54.000+0000", "updated": "2014-08-14T21:31:54.000+0000" }, { "id": "324295", "author": { "name": "jpriebe", "key": "jpriebe", "displayName": "Jason Priebe", "active": true, "timeZone": "America/New_York" }, "body": "I agree that this is a problem. \r\n\r\nI always set my defaultunit to \"dip\" for consistency across platforms.\r\n\r\nI was very surprised to find my event coordinates in pixels on android. Now I have to write a silly little special case to convert those px values to dp for android, and if you *do* fix this behavior, I will have to remove my special case.\r\n\r\nI think that in the absence of a ti.ui.defaultunit setting, all positions and dimensions should be reported in the system unit.\r\n\r\nIf the ti.ui.defaultunit setting is present, all positions and dimensions should be reported in the default unit.\r\n\r\nI would further urge that you change Studio so that it sets ti.ui.defaultunit=\"dip\" for all new projects. I think that for beginners with Titanium, the px/dp issue makes it slightly harder to build cross-platform apps with consistent UIs.\r\n\r\nIt especially hurts those developers who build their entire app for iOS first, and then think they'll have an easy time getting it to run on android (bad idea on a lot of levels, but very common). Then those users are even more frustrated than they need to be, and they go around writing nasty blog posts about Titanium.", "updateAuthor": { "name": "jpriebe", "key": "jpriebe", "displayName": "Jason Priebe", "active": true, "timeZone": "America/New_York" }, "created": "2014-09-17T18:03:06.000+0000", "updated": "2014-09-17T18:03:06.000+0000" }, { "id": "383524", "author": { "name": "amurcia", "key": "amurcia", "displayName": "Anna", "active": true, "timeZone": "America/Los_Angeles" }, "body": "@Jason Priebe I agree with you. I'm having a lot of problems because it. For me is a very big problem I'm loosing a lot of time solving it. And I'm still having problems now.", "updateAuthor": { "name": "amurcia", "key": "amurcia", "displayName": "Anna", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2016-04-21T11:22:31.000+0000", "updated": "2016-04-21T11:22:31.000+0000" } ], "maxResults": 7, "total": 7, "startAt": 0 } } }