aboutsummaryrefslogtreecommitdiffstats
path: root/examples/quick/imageelements/animatedsprite.qml
diff options
context:
space:
mode:
Diffstat (limited to 'examples/quick/imageelements/animatedsprite.qml')
-rw-r--r--examples/quick/imageelements/animatedsprite.qml24
1 files changed, 18 insertions, 6 deletions
diff --git a/examples/quick/imageelements/animatedsprite.qml b/examples/quick/imageelements/animatedsprite.qml
index cc5226882a..8666c2b9fc 100644
--- a/examples/quick/imageelements/animatedsprite.qml
+++ b/examples/quick/imageelements/animatedsprite.qml
@@ -70,19 +70,31 @@ Item {
}
//! [sprite]
+ Text {
+ text: "Left click to resume\nMiddle click to advance backward\nRight click to advance forward"
+ visible: sprite.paused
+ }
+
MouseArea {
anchors.fill: parent
- acceptedButtons: Qt.LeftButton | Qt.RightButton
+ acceptedButtons: Qt.LeftButton | Qt.RightButton | Qt.MiddleButton
onClicked: (mouse) => {
- if (!sprite.running)
+ if (!sprite.running) {
sprite.start();
- if (!sprite.paused)
+ } else if (!sprite.paused) {
sprite.pause();
- if ( mouse.button == Qt.LeftButton ) {
- sprite.advance(1);
} else {
- sprite.advance(-1);
+ if (mouse.button === Qt.LeftButton)
+ sprite.resume();
+ else if (mouse.button === Qt.MiddleButton)
+ sprite.advance(-1);
+ else if (mouse.button === Qt.RightButton)
+ sprite.advance(1);
}
}
}
+
+ Component.onCompleted: console.log("Press Space to toggle visibility. Click with mouse to pause/resume.")
+ focus: true
+ Keys.onSpacePressed: sprite.visible = !sprite.visible
}