Titanium Community Questions & Answer Archive

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

Getting coordinates of touchstart, touchend and click isn't working


I'm trying to solve this problem for a long time now and I just can't get it to work properly.

I have the following code:

var win = Titanium.UI.createWindow();

var webview = Titanium.UI.createWebView({url: 'index.html'});

win.open({fullscreen:true, navBarHidden:true});

and in the HTML File I add the event listener (in a script block after the onload event of the body):

canvas.addEventListener('touchstart', function(e)
  alert(e.x + " " + e.y);

(When I try it in the browser with 'onclick' it is working so there isn't any problem with the HTML or Javascript itself)

It alerts: "undefined undefined" and it just drives me crazy :-) Am I doing something wrong? Because according to the documentation this should work…

I really hope you could help me with this problem, I've searched the Q&A and the Docs but I just couldn't find the solution.


— asked May 11th 2010 by Michael Ziörjen
  • click
  • coordinates
  • mobile
  • touchstart

1 Answer

  • Accepted Answer


    Since this eventListener is added in a WebView, you can't use e.x and e.y shorthands - you'll have to use the full HTML/JavaScript/DOM ones, namely:

    canvas.addEventListener('touchstart', function(e) {
      alert(e.changedTouches[0].pageX + " " + e.changedTouches[0].pageY);

    Here is a great resource for touch events on the iPhone.


    — answered May 12th 2010 by Jacob Waller
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.