1

I'm writing a simple cocoa program that should use the swipe gesture. I've implemented in my NSView subclass the method swipeWithEvent: but when i try the program the method is never called. rotateWithEvent: method works instead. I'm using a Xcode 4.1 on Mac OS 10.7 Lion.

Is there a difference between rotateWithEvent: and swipeWithEvent: ?? Why the first is called when I'm under the view and do a rotate gesture and the second in the same condition is never called if i do the swipe gesture?

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

Justin Boo
  • 10,132
  • 8
  • 50
  • 71
Peter
  • 13
  • 4

2 Answers2

2

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

Oscar Del Ben
  • 4,485
  • 1
  • 27
  • 41
  • Tanks for the code. Now it works (i've enabled the desktops switch to use four finger gesture). It works with swipeWithEvent: and also the two finger gesture swipe recognizer. For the second i had to comment the following two rows in your code : 'code' // if (![self recognizeTwoFingerGestures]) // return; Do you know why [defaults boolForKey:@"AppleEnableSwipeNavigateWithScrolls"] returned always false ? Thanks in advance Peter – Peter Sep 16 '11 at 17:12
  • It's only enabled in Lion afaik. Please consider accepting the answer if it solved the problem. – Oscar Del Ben Sep 16 '11 at 19:12
0

I think it would be helpful if you posted your code, reduced down to the bare essentials if possible.

One thing to look at is to make sure 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 a rotateWithEvent: that is working correctly this is probably unlikely but sometimes a typo can creep in.

Another thing you can do is to make a sample project that does nothing but respond to a swipe by logging (or whatever). This can help identify if there is something else ii your code or view hierarchy that is getting in the way.

Jon Steinmetz
  • 4,104
  • 1
  • 23
  • 21