aboutsummaryrefslogtreecommitdiffstats
path: root/src/quick/doc/snippets/pointerHandlers/tapHandlerOverlappingButtons.qml
blob: 917c863e534b35f76049e17fa225ef183320c43a (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
39
40
41
42
43
44
45
46
47
48
49
50
51
// Copyright (C) 2023 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
//![0]
import QtQuick

Item {
    width: 120; height: 80

    component Button : Rectangle {
        signal clicked
        property alias text: buttonLabel.text

        width: 80
        height: 40
        radius: 3
        property color dark: Qt.darker(palette.button, 1.3)
        gradient: Gradient {
            GradientStop { position: 0.0; color: tapHandler.pressed ? dark : palette.button }
            GradientStop { position: 1.0; color: dark }
        }

        SequentialAnimation on border.width {
            id: tapFlash
            running: false
            loops: 3
            PropertyAction { value: 2 }
            PauseAnimation { duration: 100 }
            PropertyAction { value: 0 }
            PauseAnimation { duration: 100 }
        }

        //![1]
        TapHandler {
            id: tapHandler
            gesturePolicy: TapHandler.DragThreshold // the default
            onTapped: tapFlash.start()
        }
        //![1]

        Text {
            id: buttonLabel
            text: "Click Me"
            color: palette.buttonText
            anchors.centerIn: parent
        }
    }

    Button { x: 10; y: 10 }
    Button { x: 30; y: 30 }
}
//![0]