summaryrefslogtreecommitdiffstats
path: root/examples/declarative/listview/content/ClickAutoRepeating.qml
blob: f65c2b37271dac8bfe0866b9799f8d69cbaaa921 (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
import Qt 4.7

Item {
    id: page
    property int repeatdelay: 300
    property int repeatperiod: 75
    property bool isPressed: false

    signal pressed
    signal released
    signal clicked

    SequentialAnimation on isPressed {
        running: false
        id: autoRepeat
        PropertyAction { target: page; property: "isPressed"; value: true }
        ScriptAction { script: page.pressed() }
        ScriptAction { script: page.clicked() }
        PauseAnimation { duration: repeatdelay }
        SequentialAnimation {
            loops: Animation.Infinite
            ScriptAction { script: page.clicked() }
            PauseAnimation { duration: repeatperiod }
        }
    }
    MouseArea {
        anchors.fill: parent
        onPressed: autoRepeat.start()
        onReleased: { autoRepeat.stop(); parent.isPressed = false; page.released() }
    }
}