1

I need to catch the event of one finger right/left swipe for the Magic Mouse or two finger swipe for the Trackpad.

So far I've managed to set the event for two finger swipe on the magic mouse/ three finger on the trackpad, but this won't work in MAC OS X Lion because as of this version, this swipe is set to navigate through spaces.

[NSEvent addLocalMonitorForEventsMatchingMask:NSEventMaskSwipe handler:^(NSEvent *event) {        
    if ([event deltaX] == 1.0) { //LEFT SWIPE
        [self backHistoryAction:nil];
    } else if ([event deltaX] == -1.0) { //RIGHT SWIPE
        [self forwardHistoryAction:nil];
    }        
    return event;
}];

Thanks in advance.

Mikywan.

mikywan
  • 1,495
  • 1
  • 19
  • 38

2 Answers2

0

https://github.com/Kapeli/SwipableWebView/ is a WebView subclass that adds support for two-finger swipes (trackpad) and one-finger swipes (Magic Mouse). It should be trivial to port that code to support swipes in any other NSView.

bogdansrc
  • 1,338
  • 2
  • 15
  • 28
0

There’s a new API for swipes in Lion. See the AppKit release notes.

Jens Ayton
  • 14,532
  • 3
  • 33
  • 47