Titanium Community Questions & Answer Archive

We felt that 6+ years of knowledge should not die so this is the Titanium Community Questions & Answer Archive

Touch event bug == really really stupid

There is a really ridiculously ridiculous bug associated with View touch events.
Given a setup such as:

var view1 = Ti.UI.createView({
width:200, height:200
});

var view2 = Ti.UI.createView({
width:100, height:100, top:50, left:50
});

view1.add(view2);

view1.addEventListener('touchstart', function(evt){
Ti.API.info('evtX = ' + evt.x + 'evtY = ' + evt.y );
});

What happens is that if the touch event occurs inside view2, the coordinates
recorded by the event are relative to view2, and not view1, which of course is the source that actually fires the event, and is indeed recorded as the source of the event.

Am I taking crazy pills? Or should I start taking crazy pills to make this seem more logical? It is very frustrating not being able to trust the API generated values without having to incorporate a bunch of extra fluff (such as a transparent 'cover view' with greatest zIndex whose only function is to recieve touch events). Not a very happy camper in these woods.

— asked December 7th 2010 by Fredrik Carlsson
  • bug
  • coordinates
  • event
  • incorrect
  • mobile
  • touch
  • view
0 Comments

1 Answer

  • Agreed, it'd be nice to get the coordinates relative to the view that the event was added to.

    — answered January 27th 2011 by Marshall Jones
    permalink
    0 Comments
The ownership of individual contributions to this community generated content is retained by the authors of their contributions.
All trademarks remain the property of the respective owner.