I tried this var isTrackPad = wheel.pixelDelta.== Qt,point(0;0);
as this says.
But it seems pixelDelta works only on Mac. Is there other method to check if a wheel event is from mouse wheel or touchpad on Windows?
onWheel: {
var horizontal = false;
var isTrackPad = wheel.pixelDelta !== Qt.point(0,0);
if (Math.abs(wheel.angleDelta.x) > Math.abs(wheel.angleDelta.y)) {
delta = wheel.angleDelta.x
horizontal = true
}
else {
delta = wheel.angleDelta.y
}
if ((isTrackPad && horizontal) || (!isTrackPad && wheel.modifiers === xxx.ScrollModifiersH)) {
...
}
}
You could try WheelHandler
instead like the following. I can't tell if it will work on Windows as I'm using Linux and there the Mouse is the same as the Touchpad.
Note: Some non-mouse hardware (such as a touch-sensitive Wacom tablet, or a Linux laptop touchpad) generates real wheel events from gestures. WheelHandler will respond to those events as wheel events even if acceptedDevices remains set to its default value.
WheelHandler {
acceptedDevices: PointerDevice.Mouse
onWheel: console.log("WheelHandler", "Mouse")
}
WheelHandler {
acceptedDevices: PointerDevice.TouchPad
onWheel: console.log("WheelHandler", "TouchPad")
}
Or you can get the QInputDevice::DeviceType from the WheelEvent . But same story here, if your OS doesn't make a difference between mouse or touchpad it will always give you QInputDevice::DeviceType::Mouse
. The matching enum in QML is PointerDevice.Mouse
.
MouseArea {
anchors.fill: parent
onWheel: function(wheelEvent) {
console.log("device", wheelEvent.device.type)
}
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.