如何在 Mac 触控板上获取指点设备的坐标?
当用户在触控板上做出手势时,我想获取手指的位置。
我已经迷上了滑动时触发的 swipeWithEvent 。在该 NSEvent 中,有一个方法 deltaX 报告运动的变化。还有absoluteX方法看起来很有希望,但除了以下断言失败之外,我无法返回任何内容:
发送到事件“NSEvent: type=Swipe loc=(394,335) time=3893.8 flags=0x100 win=0x10022fdc0 winNum的消息无效” =586 ctxt=0x0 deltaX=-1.000000 deltaY=0.000000"
错误消息中的“loc”值随着时间的推移略有变化,但据我了解,这不是正确的值,因为变化太小。
那么,如何在触控板上正确使用 NSEvent 的absoluteX?
I'd like to get the finger's position when user makes a gesture on the trackpad.
I've already hooked on to swipeWithEvent that triggers on swipe. Within that NSEvent there's a method deltaX that reports the change of the movement. There's also absoluteX method that looks promising, but I can't get it to return anything but the following assertion failure:
Invalid message sent to event "NSEvent: type=Swipe loc=(394,335) time=3893.8 flags=0x100 win=0x10022fdc0 winNum=586 ctxt=0x0 deltaX=-1.000000 deltaY=0.000000"
The 'loc' value the in the error message changes a bit over time, but to my understanding it's not the right value because the change is too small.
So, how can I properly use NSEvent's absoluteX on a trackpad?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
来自
-[NSEvent AbsoluteX]
的文档:我认为如果您需要在非平板电脑设备上获取相同的信息,您需要告诉 Apple(通过错误报告器或 DTS)您的要求,因为 API 目前不支持它。
From the documentation for
-[NSEvent absoluteX]
:I would think if you need to get the same information on a non-tablet device, you need to tell Apple (via the bug reporter or DTS) about your requirement as the API doesn't currently support it.