Mojo.Event.tap - how to get faucet coordinates?
I'm having a hard time figuring out how to get the tap coordinates from the tapEvent object that's passed to my custom handler (I couldn't find its spec anyway). There is also a singleTap event that passes custom variables "X" as "Y" which I assume are coordinates, but I cannot call that code in the emulator.
The thing is, I am working on one application where I have a large element and I need to know exactly where the user clicked (this could be the global screen coordinate or the relative coordinate of my element).
Here's some sample code:
//inside of assistant setup method:
Mojo.Event.listen(this.controller.get('elem'), Mojo.Event.tap, this.listenSingleTap.bindAsEventListener(this));
//custom handler:
SomeAssistant.prototype.listenSingleTap = function(singleTapEvent){
this.someOtherMethod(singleTapEvent.x, singleTapEvent.y); //This is wrong and doesn't work - how I suppose to get tap coordinates?
}
Thanks a lot for any suggestions.
+2
source to share
1 answer
The x and y coordinates for the tap event are in the "down" property of the event.
Ex.
MyAssistant.prototype.setup = function() {
Mojo.Event.listen(this.controller.get('elem'), Mojo.Event.tap, this.handleTap.bind(this));
}
MyAssistant.prototype.handleTap = function(event) {
Mojo.Log.info("tap down at x: " + event.down.x + " y: " + event.down.y);
}
+4
source to share