aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/quick/pointerhandlers/qquickpointerhandler/data/dynamicallyCreated.qml
diff options
context:
space:
mode:
authorShawn Rutledge <shawn.rutledge@qt.io>2018-11-22 14:00:39 +0100
committerShawn Rutledge <shawn.rutledge@qt.io>2018-12-07 20:45:10 +0000
commitee2ac69595d3f854f7bf7158e600091f2675fa18 (patch)
tree50ef6ecedadd96ac1c563e65f16f28dd1ded2943 /tests/auto/quick/pointerhandlers/qquickpointerhandler/data/dynamicallyCreated.qml
parent1cd3b2acfeb041ef54fe546b07a5e9efb5a2099b (diff)
Add dynamically-created Event Handlers to the relevant handlers vector
If any kind of Pointer Handler is created dynamically in JS by calling Component.createObject(), QObject::setParent() is called rather than passing the parent to the constructor, so QQuickItemPrivate::data_append() did not take care of adding the handler to QQuickItemPrivate's extra->pointerHandlers vector. We need to use the auto-parent mechanism (just as we did with handling dynamic creation of nested Windows in 8cb02e23abbefc9d020707fc1a2d8b6eb4e103b6). Added QQuickItemPrivate::addPointerHandler() to put the prepend() and implied setAcceptedMouseButtons() in one place. Fixes: QTBUG-71427 Change-Id: I3be3dd033c1c89e6e5b5c3463e1a720bbe963281 Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
Diffstat (limited to 'tests/auto/quick/pointerhandlers/qquickpointerhandler/data/dynamicallyCreated.qml')
-rw-r--r--tests/auto/quick/pointerhandlers/qquickpointerhandler/data/dynamicallyCreated.qml34
1 files changed, 34 insertions, 0 deletions
diff --git a/tests/auto/quick/pointerhandlers/qquickpointerhandler/data/dynamicallyCreated.qml b/tests/auto/quick/pointerhandlers/qquickpointerhandler/data/dynamicallyCreated.qml
new file mode 100644
index 0000000000..8f774a7ec3
--- /dev/null
+++ b/tests/auto/quick/pointerhandlers/qquickpointerhandler/data/dynamicallyCreated.qml
@@ -0,0 +1,34 @@
+import QtQuick 2.12
+import Qt.test 1.0
+
+Item {
+ id: root
+ objectName: "root Item"
+ width: 320
+ height: 480
+
+ Rectangle {
+ objectName: "eventItem's bounds"
+ anchors.fill: eventItem
+ color: "lightsteelblue"
+ }
+
+ EventItem {
+ id: eventItem
+ objectName: "eventItem1"
+ x: 5
+ y: 5
+ height: 30
+ width: 30
+
+ Component.onCompleted: handlerComponent.createObject(eventItem)
+
+ Component {
+ id: handlerComponent
+
+ EventHandler {
+ objectName: "eventHandler"
+ }
+ }
+ }
+}