aboutsummaryrefslogtreecommitdiffstats
path: root/src/quick/doc/snippets/pointerHandlers/tapHandlerButton.qml
diff options
context:
space:
mode:
Diffstat (limited to 'src/quick/doc/snippets/pointerHandlers/tapHandlerButton.qml')
-rw-r--r--src/quick/doc/snippets/pointerHandlers/tapHandlerButton.qml33
1 files changed, 33 insertions, 0 deletions
diff --git a/src/quick/doc/snippets/pointerHandlers/tapHandlerButton.qml b/src/quick/doc/snippets/pointerHandlers/tapHandlerButton.qml
new file mode 100644
index 0000000000..1cd332a2de
--- /dev/null
+++ b/src/quick/doc/snippets/pointerHandlers/tapHandlerButton.qml
@@ -0,0 +1,33 @@
+// Copyright (C) 2021 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+//![0]
+import QtQuick
+
+Rectangle {
+ id: button
+ signal clicked
+ property alias text: buttonLabel.text
+
+ height: Math.max(Screen.pixelDensity * 7, buttonLabel.implicitHeight * 1.2)
+ width: Math.max(Screen.pixelDensity * 11, buttonLabel.implicitWidth * 1.3)
+ 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 }
+ }
+
+ TapHandler {
+ id: tapHandler
+ gesturePolicy: TapHandler.ReleaseWithinBounds
+ onTapped: button.clicked()
+ }
+
+ Text {
+ id: buttonLabel
+ text: "Click Me"
+ color: palette.buttonText
+ anchors.centerIn: parent
+ }
+}
+//![0]