aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/quick/qquickmousearea/data
diff options
context:
space:
mode:
authorShawn Rutledge <shawn.rutledge@theqtcompany.com>2016-03-04 11:02:54 +0100
committerShawn Rutledge <shawn.rutledge@theqtcompany.com>2016-03-11 12:15:26 +0000
commit644a6a42a45ceb9790df6d6ee1c3ba43c7b9ab10 (patch)
tree493c315698238fb1736cbd29d90a52d5351feb0a /tests/auto/quick/qquickmousearea/data
parent6300f4dde0ab3279b18a0fb29f94cfe142557cba (diff)
MouseArea: add source property to mouse event
It comes from the source() of the QMouseEvent which triggered it. This makes it possible to distinguish real mouse events from those that are synthesized from touch or tablet. And for this we need to import QtQuick 2.7 [ChangeLog][QtQuick][MouseArea] Added mouse.source property to enable distinguishing genuine mouse events from those that are synthesized from touch or tablet events. Change-Id: I568964f63981703bd23e05daac5288518f09d837 Reviewed-by: Robin Burchell <robin.burchell@viroteck.net>
Diffstat (limited to 'tests/auto/quick/qquickmousearea/data')
-rw-r--r--tests/auto/quick/qquickmousearea/data/ignoreBySource.qml31
1 files changed, 31 insertions, 0 deletions
diff --git a/tests/auto/quick/qquickmousearea/data/ignoreBySource.qml b/tests/auto/quick/qquickmousearea/data/ignoreBySource.qml
new file mode 100644
index 0000000000..a53cbf7b1d
--- /dev/null
+++ b/tests/auto/quick/qquickmousearea/data/ignoreBySource.qml
@@ -0,0 +1,31 @@
+import QtQuick 2.7
+
+Item {
+ id: root
+ // by default you can flick via touch or tablet but not via mouse
+ property int allowedSource: Qt.MouseEventNotSynthesized
+ property int lastEventSource: -1
+ width: 200
+ height: 200
+ Flickable {
+ objectName: "flickable"
+ anchors.fill: parent
+ contentWidth: 400
+ contentHeight: 400
+ Rectangle {
+ color: ma.pressed ? "yellow" : "steelblue"
+ width: 200
+ height: 200
+ }
+ }
+ MouseArea {
+ id: ma
+ objectName: "mousearea"
+ onPressed: {
+ root.lastEventSource = mouse.source
+ if (mouse.source !== root.allowedSource)
+ mouse.accepted = false
+ }
+ anchors.fill: parent
+ }
+}