-[NSResponder swipeWithEvent:] not called

瘦欲@ 提交于 2019-12-04 04:10:32

To receive swipeWithEvent: messages, you have to ensure that the 3 finger swipe gesture is not mapped to anything that might cause a conflict. Go to System preferences -> Trackpad -> More Gestures, and set these preferences to one of the following:

  • Swipe between pages:

    1. Swipe with two or three fingers, or
    2. Swipe with three fingers

  • Swipe between full-screen apps:

    1. Swipe left or right with four fingers

Specifically, the swipe between full-screen apps should not be set to three fingers, otherwise you will not get swipeWithEvent: messages.

Together, these two preference settings cause swipeWithEvent: messages to be sent to the first responder.

Of course, you still have to implement the actual swipe logic. And if you want to perform a fluid scroll-swipe à la iOS, then you will need to do a little more work. There is an example of how to do this in the Lion App Kit release notes under the section "Fluid Swipe Tracking."

See http://developer.apple.com/library/mac/#releasenotes/Cocoa/AppKit.html

Jonas

try with [self setAcceptsTouchEvents:YES]; where it says // Initialization code here.

Not sure if it's the problem, but only the key window receives Gestures. Is your window key?

Is your view accepting first responders?

- (BOOL) acceptsFirstResponder
{
  return YES;
}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!