Mojo.Event.tap - 如何获取点击坐标?
我很难找出如何从 tapEvent 对象获取点击坐标,该对象被传递给我的自定义处理程序(无论如何我都没有找到它的规范)。还有 singleTap 事件,它将自定义变量“X”传递为“Y”,我猜这是坐标,但我无法在模拟器中调用该事件。
关键是我正在开发一个应用程序,其中我有一个大元素,我需要知道用户点击的确切位置(可能是全局屏幕坐标或我的元素的相对坐标)。
这是示例代码:
//inside of assistant's 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?
}
非常感谢您的任何建议。
I am having difficulty with finding out how to get tap coordinates from tapEvent object, which is passed to my custom handler (I didn't find it's specification anyway). There is also singleTap event, which passes custom variables "X" as "Y", which is coordinates, i guess, but I can't invoke that one in Emulator.
The point is that I am working on one application, where I have big element and I need to know where exactly user tapped (it maybe global screen coordinate or relative coordinate of my element).
Here is example code:
//inside of assistant's 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?
}
Thank you very much for any suggestions.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
点击事件的 x 和 y 坐标位于事件的“down”属性中。
前任。
The x and y coordinates for the tap event are in the "down" property of the event.
Ex.