mac: Don't interpret single-touch scroll events as pan gestures
To handle the Magic Mouse, whose single-finger touch gestures should be interpreted as scrollwheel events rather than pan gestures.
This commit is contained in:
parent
85f6ec4144
commit
91db627a81
@ -372,6 +372,7 @@ MenuBarRef GetOrCreateMainMenu(bool *unique) {
|
||||
double rotationGestureCurrent;
|
||||
Point2d trackpadPositionShift;
|
||||
bool inTrackpadScrollGesture;
|
||||
int numTouches;
|
||||
Platform::Window::Kind kind;
|
||||
}
|
||||
|
||||
@ -397,6 +398,8 @@ MenuBarRef GetOrCreateMainMenu(bool *unique) {
|
||||
editor.action = @selector(didEdit:);
|
||||
|
||||
inTrackpadScrollGesture = false;
|
||||
numTouches = 0;
|
||||
self.acceptsTouchEvents = YES;
|
||||
kind = aKind;
|
||||
if(kind == Platform::Window::Kind::TOPLEVEL) {
|
||||
NSGestureRecognizer *mag = [[NSMagnificationGestureRecognizer alloc] initWithTarget:self
|
||||
@ -573,7 +576,9 @@ MenuBarRef GetOrCreateMainMenu(bool *unique) {
|
||||
using Platform::MouseEvent;
|
||||
|
||||
MouseEvent event = [self convertMouseEvent:nsEvent];
|
||||
if(nsEvent.subtype == NSEventSubtypeTabletPoint && kind == Platform::Window::Kind::TOPLEVEL) {
|
||||
// Check for number of touches to exclude single-finger scrolling on Magic Mouse
|
||||
bool isTrackpadEvent = numTouches >= 2 && nsEvent.subtype == NSEventSubtypeTabletPoint;
|
||||
if(isTrackpadEvent && kind == Platform::Window::Kind::TOPLEVEL) {
|
||||
// This is how Cocoa represents 2 finger trackpad drag gestures, rather than going via
|
||||
// NSPanGestureRecognizer which is how you might expect this to work... We complicate this
|
||||
// further by also handling shift-two-finger-drag to mean rotate. Fortunately we're using
|
||||
@ -626,6 +631,23 @@ MenuBarRef GetOrCreateMainMenu(bool *unique) {
|
||||
receiver->onMouseEvent(event);
|
||||
}
|
||||
|
||||
- (void)touchesBeganWithEvent:(NSEvent *)event {
|
||||
numTouches = [event touchesMatchingPhase:NSTouchPhaseTouching inView:self].count;
|
||||
[super touchesBeganWithEvent:event];
|
||||
}
|
||||
- (void)touchesMovedWithEvent:(NSEvent *)event {
|
||||
numTouches = [event touchesMatchingPhase:NSTouchPhaseTouching inView:self].count;
|
||||
[super touchesMovedWithEvent:event];
|
||||
}
|
||||
- (void)touchesEndedWithEvent:(NSEvent *)event {
|
||||
numTouches = [event touchesMatchingPhase:NSTouchPhaseTouching inView:self].count;
|
||||
[super touchesEndedWithEvent:event];
|
||||
}
|
||||
- (void)touchesCancelledWithEvent:(NSEvent *)event {
|
||||
numTouches = 0;
|
||||
[super touchesCancelledWithEvent:event];
|
||||
}
|
||||
|
||||
- (void)mouseExited:(NSEvent *)nsEvent {
|
||||
using Platform::MouseEvent;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user