macOS Trackpad Gestures - Simultaneous Pinch & Pan?
-
On macOS with multitouch trackpad (so: traditional macOS desktop app utilizing Macbook trackpad, Magic Mouse, etc), I would like to handle two gestures simultaneously:
- User pinching to zoom in/out
- User moving hand (while pinching) to pan around
So, simultaneously I want my object to scale as the user pinches in/out AND follow the center point of that pinch around the screen to move it while it scales.
I find the best luck getting pinch-to-zoom data from
QNativeGestureEvent:if event.type() == QtCore.QEvent.Type.NativeGesture and \ event.gestureType() == QtCore.Qt.NativeGestureType.ZoomNativeGesture: print("Zoom delta:", event.value())And I can get two-finger pan gesture info from
QWheelEvent:if event.type() == QtCore.QEvent.Type.Wheel: print("Wheel delta:", event.angleDelta())However, if the user is zooming, I do not get QWheelEvents reported. And if the user is panning, I do not get the native gestures reported.
Furthermore, any positional info I get from the
QNativeGestureEventduring pinch (frompos(), etc) is not updated -- it just reports the centerpoint as it was when the pinch was initiated, but does not move "live." Experimented withsetMouseTracking(True)on the widget but that didn't update center points live. -
On macOS with multitouch trackpad (so: traditional macOS desktop app utilizing Macbook trackpad, Magic Mouse, etc), I would like to handle two gestures simultaneously:
- User pinching to zoom in/out
- User moving hand (while pinching) to pan around
So, simultaneously I want my object to scale as the user pinches in/out AND follow the center point of that pinch around the screen to move it while it scales.
I find the best luck getting pinch-to-zoom data from
QNativeGestureEvent:if event.type() == QtCore.QEvent.Type.NativeGesture and \ event.gestureType() == QtCore.Qt.NativeGestureType.ZoomNativeGesture: print("Zoom delta:", event.value())And I can get two-finger pan gesture info from
QWheelEvent:if event.type() == QtCore.QEvent.Type.Wheel: print("Wheel delta:", event.angleDelta())However, if the user is zooming, I do not get QWheelEvents reported. And if the user is panning, I do not get the native gestures reported.
Furthermore, any positional info I get from the
QNativeGestureEventduring pinch (frompos(), etc) is not updated -- it just reports the centerpoint as it was when the pinch was initiated, but does not move "live." Experimented withsetMouseTracking(True)on the widget but that didn't update center points live.@mjiggidyj said in macOS Trackpad Gestures - Simulatneous Pinch & Pan?:
any positional info I get from the QNativeGestureEvent during pinch (from pos(), etc) is not updated
What about https://doc.qt.io/qt-6/qnativegestureevent.html#delta ?