summaryrefslogtreecommitdiff
path: root/tests/auto/qml/qmlcppcodegen/data/pressAndHoldButton.qml
blob: 9750bb3a1d74bb2a112540562c7dd5dc30cdded4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import QtQuick

Image {
    id: container

    property int repeatDelay: 300
    property int repeatDuration: 75
    property bool pressed: false

    signal clicked

    scale: pressed ? 0.9 : 1

    function press() {
        autoRepeatClicks.start();
    }

    function release() {
        autoRepeatClicks.stop()
        container.pressed = false
    }

    ParallelAnimation on pressed {
        id: autoRepeatClicks
        running: false

        PropertyAction { target: container; property: "pressed"; value: true }
        ScriptAction { script: container.clicked() }
        PauseAnimation { duration: container.repeatDelay }

        ParallelAnimation {
            loops: Animation.Infinite
            ScriptAction { script: container.clicked() }
            PauseAnimation { duration: container.repeatDuration }
        }
    }
}