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

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

问题描述

我正在寻找一种方法来在用户输入设备具有一维滚动轮或二维trackPad/magicMouse的情况下在[NSResponder scrollWheel:]中可靠地区分?

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)

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

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