如何获得相对于窗口的用户点击/触摸的x和y坐标-Android Titan Mobile? [英] how to get x and y coordinates of user tap/touch relative to window - android titanium mobile?

查看:141
本文介绍了如何获得相对于窗口的用户点击/触摸的x和y坐标-Android Titan Mobile?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

任何人都可以说出如何获取相对于窗口的用户点击/触摸的x和y坐标-Android Titan Mobile吗?

Can any one tell how to get x and y coordinates of user tap/touch relative to window - android titanium mobile??

当用户选择一行时,我需要在tableviewrow附近添加一个弹出视图.如何确定x,y(顶部/左侧)位置?

I need to add a popup view close to tableviewrow when the user select a row. How to determine the x,y (top/left) positions?

推荐答案

您可以使用

row.addEventListener('click',function(e){
    alert('left:'+ e.x + ' top:'+ e.y);
});

其中row是Titanium.UI.TableViewRow的对象.对于其他对象(例如窗口/视图),可以使用相同的事件监听器.

where row is an object of Titanium.UI.TableViewRow. For other objects (like window/view), you can use same eventlistener.

但是请记住一件事:它给出了对应行的坐标.也就是说,所有行的坐标都可能相同.

But remember one thing: it gives the co-ordinates with respect to the corresponding row. i.e. you may get same co-ordinates for all the rows.

因此,如果要在该坐标上弹出某些内容,则应addEventListener到主窗口.

Therefor, if you want to popup something on that co-ordinate, you should addEventListener to the main window.

这篇关于如何获得相对于窗口的用户点击/触摸的x和y坐标-Android Titan Mobile?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆