- (void) swipeWithEvent: (NSEvent *) event not working on Lion?

I am writing a simple cocoa program that should use swipe gestures. I have implemented the swipeWithEvent: method in my NSView subclass, but when I try to run the program, the method is never called. Instead, rotateWithEvent: works. I am using Xcode 4.1 on Mac OS 10.7 Lion.

Is there a difference between rotateWithEvent: and swipeWithEvent: :? Why is the first called when I'm disguised and perform a swivel gesture, and the second in the same state is never called if I make a swipe gesture?

Update: I also built a simple project only to test the swipeWithEvent: and rotateWithEvent: methods, but the behavior is the same.

+1
source share
2 answers

Take a look at this sample code that I wrote https://github.com/oscardelben/CocoaNavigationGestures

+2
source

I think it would be useful if you posted your code, reducing it to a minimum size, if possible.

One thing you need to pay attention to is to make sure that the method signature exactly matches the definition. In this case, it should be:

 - (void) swipeWithEvent: (NSEvent*) event { NSLog( @"A swipe happened" ); } 

Make sure your definition matches this. Since you have rotateWithEvent: it works correctly, this is probably unlikely, but a typo can sometimes fill up.

Another thing you can do is create a sample project that does nothing but respond to napkins by keeping a journal (or something else). This can help determine if there is anything else in your code or view hierarchy that is interfering.

0
source

All Articles