QNativeGestureEvent does not pick up SwipeNativeGesture on Mac OS X?
-
Hi all,
I was trying to implement native gesture support for my Mac app. It appears QNativeGestureEvent can only pick up native zoom and rotate gesture, but not swipe gesture on the touch pad. If I print out the event, all I get is a BeginNativeGesture and a EndNativeGesture with value unchanged. Has anyone else successfully implemented native swipe gesture in their code?
Thank you!
-
I confirm...
QAbstractScrollArea->grabGesture(Qt::SwipeGesture, Qt::ReceivePartialGestures);
only swipe distance is registred... can use 4 zoom not to chance page like ebook reader or so..but in qt5 code is here qnsview.mm .. line 1350
i try to pic up the event on qmainwindow core..- (void)swipeWithEvent:(NSEvent *)event { if (!m_platformWindow) return; qCDebug(lcQpaGestures) << "swipeWithEvent" << [event deltaX] << [event deltaY]; const NSTimeInterval timestamp = [event timestamp]; QPointF windowPoint; QPointF screenPoint; [self convertFromScreen:[self screenMousePoint:event] toWindowPoint:&windowPoint andScreenPoint:&screenPoint]; qreal angle = 0.0f; if ([event deltaX] == 1) angle = 180.0f; else if ([event deltaX] == -1) angle = 0.0f; else if ([event deltaY] == 1) angle = 90.0f; else if ([event deltaY] == -1) angle = 270.0f; QWindowSystemInterface::handleGestureEventWithRealValue(m_platformWindow->window(), timestamp, Qt::SwipeNativeGesture, angle, windowPoint, screenPoint); }
Waht is work is this: (no axis)
/// mac trackpad https://support.apple.com/en-us/HT204895 bool DrawDocument::gestureNative(QNativeGestureEvent *e) { if (e->type() == QEvent::NativeGesture) { if (e->value() < 0) { distanceswip = distanceswip - e->value(); setZoom(scaleFaktor - TRACKPADSTEEPS); } else { distanceswip = distanceswip + e->value(); setZoom(scaleFaktor + TRACKPADSTEEPS); } } return true; }