如何实现两个手指滑动手势在Cocoa回去和前进? [英] How to implement the two-finger swipe gesture in Cocoa to go back and forward?

查看:141
本文介绍了如何实现两个手指滑动手势在Cocoa回去和前进?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


当您用两个滑动手指滑动时,Safari和Finder之间的几个应用程序会反向

Several applications like Safari and the Finder go back and forward when you swipe with two fingers on your Magic Mouse (or with three fingers on your Magic Trackpad).

如何在Cocoa应用程序中实现这个功能?

How would I implement this in my Cocoa application? What classes are available?

推荐答案

三指滑动是最简单的,因为NSResponder已经为您完成了工作:

Three finger swipes are easiest, because NSResponder already does the work for you:

- (void)swipeWithEvent:(NSEvent *)event;

如果您想支持两次手指滑动(我不认为技术上可以归类为滑动,而是滚动手势),则必须手动处理触摸事件 - 请参阅 http://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/EventOverview/HandlingTouchEvents/HandlingTouchEvents.html#//apple_ref/ doc / uid / 10000060i-CH13-SW10

If you want to support two finger swipes (which I don't think technically can be classified as swipes, but rather scroll gestures), you'll have to manually process the touches- see http://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/EventOverview/HandlingTouchEvents/HandlingTouchEvents.html#//apple_ref/doc/uid/10000060i-CH13-SW10

这篇关于如何实现两个手指滑动手势在Cocoa回去和前进?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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