aboutsummaryrefslogtreecommitdiffstats
path: root/examples/quick/pointerhandlers/components/MouseFeedbackSprite.qml
diff options
context:
space:
mode:
authorShawn Rutledge <shawn.rutledge@qt.io>2020-05-06 22:37:33 +0200
committerShawn Rutledge <shawn.rutledge@qt.io>2021-12-10 06:52:06 +0100
commitcd5d62e9997c71e2105d571f681777c5a59c3ef1 (patch)
tree59bfd9a2dd1a0bfbf2de964f335d98022b03c341 /examples/quick/pointerhandlers/components/MouseFeedbackSprite.qml
parente58cb58b44a0381592cd0e6eb0da3d3d6f1c5ccc (diff)
Pointer Handlers example: show mouse wheel feedback
MouseFeedbackSprite now shows a mouse wheel animating in the same direction as the physical mouse wheel is being rotated. Change-Id: I08709ead3b85065723d2320d17d49adb51a00f92 Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
Diffstat (limited to 'examples/quick/pointerhandlers/components/MouseFeedbackSprite.qml')
-rw-r--r--examples/quick/pointerhandlers/components/MouseFeedbackSprite.qml28
1 files changed, 25 insertions, 3 deletions
diff --git a/examples/quick/pointerhandlers/components/MouseFeedbackSprite.qml b/examples/quick/pointerhandlers/components/MouseFeedbackSprite.qml
index 0fa2db3aa7..276627a732 100644
--- a/examples/quick/pointerhandlers/components/MouseFeedbackSprite.qml
+++ b/examples/quick/pointerhandlers/components/MouseFeedbackSprite.qml
@@ -50,15 +50,14 @@
import QtQuick
-PointHandler {
+HoverHandler {
id: handler
objectName: "mouse point"
acceptedDevices: PointerDevice.Mouse
- acceptedButtons: Qt.AllButtons
target: Image {
objectName: "mouse sprite"
source: "images/mouse.png"
- visible: handler.active
+ opacity: (handler.point.pressedButtons || wheelAnimationTimer.running) ? 1 : 0
x: handler.point.position.x - width / 2
y: handler.point.position.y - height / 2
parent: handler.parent
@@ -74,5 +73,28 @@ PointHandler {
source: "images/mouse_right.png"
visible: handler.point.pressedButtons & Qt.RightButton
}
+ WheelHandler {
+ blocking: false
+ onWheel: (event)=> {
+ wheelSprite.reverse = (event.angleDelta.y < 0)
+ wheelAnimationTimer.start()
+ }
+ }
+ AnimatedSprite {
+ id: wheelSprite
+ x: 19
+ y: 7
+ source: "images/mouse_wheel_ridges.png"
+ frameWidth: 5
+ frameHeight: 15
+ frameCount: 3
+ frameDuration: 50
+ running: wheelAnimationTimer.running
+ visible: running
+ Timer {
+ id: wheelAnimationTimer
+ interval: 500
+ }
+ }
}
}