Cocoa:区分输入设备/scrollWheel:作为鼠标滚轮和TrackPad [英] Cocoa: distinguish input device / scrollWheel: as mouse-scroll wheel and TrackPad

查看:27
本文介绍了Cocoa:区分输入设备/scrollWheel:作为鼠标滚轮和TrackPad的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在寻找一种方法来在 [NSResponder scrollWheel:] 中可靠地区分用户输入设备是否具有一维滚轮或二维轨迹板/magicMouse?

I am looking for a method to reliably distinguish within [NSResponder scrollWheel:] if the users input device has a one-dimensional scroll-wheel or a two dimensional trackPad/magicMouse?

首先,我想实现不同的行为.但是仅仅看一下 NSEvent 的 deltaX 会有点弱.有什么建议吗?

In the first I would like to implement a different behavior. But just taking a look on the deltaX of the NSEvent would be a little weak. Any suggestions?

推荐答案

您可以使用私有方法调用 [theEvent _scrollPhase] 来判断设备是否使用惯性滚动,这表明 Apple-提供的输入设备.(注意:如果用户禁用了惯性滚动,这将不起作用)

You can use the private method call [theEvent _scrollPhase] to tell whether the device is using inertial scrolling, which indicates an Apple-supplied input device. (Note: this won't work if the user has disabled inertial scrolling)

这篇关于Cocoa:区分输入设备/scrollWheel:作为鼠标滚轮和TrackPad的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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