Uploaded image for project: 'Titanium SDK/CLI'
  1. Titanium SDK/CLI
  2. TIMOB-17409

Both Ti.UI.View.rect and event coordinates should use the (same) documented unit

    Details

    • Type: Bug
    • Status: Open
    • Priority: Medium
    • Resolution: Unresolved
    • Affects Version/s: Release 3.3.0
    • Fix Version/s: None
    • Component/s: Android, iOS
    • Environment:

      SDK 3.3.0.RC

      Description

      While making the 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.

      The documentation of 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.

      When 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.

      The documentation should be fixed, but I'd also request for both to use the same units, be it system or default unit.

      console.debug(Ti.App.Properties.getString('ti.ui.defaultunit'));
      var win = Ti.UI.createWindow({backgroundColor:'white'});
      win.addEventListener('postlayout', function(e) {
          console.debug('rect: ' + win.rect.width + ',' + win.rect.height);
      });
      win.addEventListener('click', function(e) {
          console.debug('click: ' + e.x + ',' + e.y);
      });
      win.open();
      

      iOS

      ti.ui.defaultunit rect click
      (none) dp dp
      px px dp
      dp dp dp

      Android

      ti.ui.defaultunit rect click
      (none) px px
      px px px
      dp dp px

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              fokkezb Fokke Zandbergen
            • Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:

                Backbone Issue Sync

                • Titanium SDK/CLI <> Titanium Mobile
                  Synced with:
                  TIMOB-19007
                  Sync status:
                  ERROR
                  Last received:
                  Last sent:

                  Git Integration