本文介绍了如何在OS X中实现手势识别器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经为iOS的手势识别器做了很多工作,但是我现在正在OS X中进行工作,我迷路了.

I have done quite a bit with gesture recognizers for iOS, but I am now doing work in OS X, and I am lost.

我想复制Finder中存在的功能,在该功能中您可以用两根手指滑动(在魔术鼠标上)在目录树中来回/前进.

I want to duplicate the functionality that exists like in Finder where you can two-finger swipe (on your magic mouse) to go back/forward through a directory tree.

我有一个基于NSWindow的应用程序,看起来与Finder非常相似.在此之前,我已经使用过应用程序,因此您可以构建自己的手势识别器,因此我知道可以做到这一点,但是我看不到任何文档.

I have an NSWindow based app that looks very similar to Finder. I have used apps before that allows you to build your own gesture recognizers so I know it is possible to do it, but I don't see any documentation on it.

要实现这些手势我需要做什么?

What do I need to do to implement these gestures?

推荐答案

您可以阅读有关处理触控板事件.该系统可以检测到一些预定义的手势(滑动,旋转等),或者您可以像在常规鼠标事件一样,沿着NSResponder链监听原始的触摸事件.

You can read about Handling Trackpad Events in the Cocoa Event Handling guide. The system can detect some pre-defined gestures (swipe, rotate, etc.) or you can listen to the raw touch events, which travel up the NSResponder chain, just like regular mouse events.

这篇关于如何在OS X中实现手势识别器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-04 21:47