diff options
author | Jan Arve Saether <jan-arve.saether@qt.io> | 2016-12-23 15:30:33 +0100 |
---|---|---|
committer | Jan Arve Sæther <jan-arve.saether@qt.io> | 2016-12-29 10:27:49 +0000 |
commit | 70113ef66b245e58ce12e2a9d26268e2eaeb3a42 (patch) | |
tree | c3882090db4e76aac1e5c5e7c8da13b41db4806c /src/quick/items/qquickitem.cpp | |
parent | 953b5070160a3a1bed7aaf986a1bb1c3b33b0dca (diff) |
Don't assume that target is the parent item
To summarize: A pointer handler always gets its pointer events from its
parent item. It applies its effect (drag, pinch, ...) on the item
referenced to by the target property. By default, target refers to the
parent, but that is not always the case. In addition to this we also
have to handle the case when the target is null
Change-Id: If62108abf0aeb713906bf88472ad9a32a74efff6
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
Diffstat (limited to 'src/quick/items/qquickitem.cpp')
-rw-r--r-- | src/quick/items/qquickitem.cpp | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/src/quick/items/qquickitem.cpp b/src/quick/items/qquickitem.cpp index 97a4e51def..55e82a7a4d 100644 --- a/src/quick/items/qquickitem.cpp +++ b/src/quick/items/qquickitem.cpp @@ -3222,7 +3222,12 @@ void QQuickItemPrivate::data_append(QQmlListProperty<QObject> *prop, QObject *o) if (o->inherits("QGraphicsItem")) qWarning("Cannot add a QtQuick 1.0 item (%s) into a QtQuick 2.0 scene!", o->metaObject()->className()); else if (QQuickPointerHandler *pointerHandler = qmlobject_cast<QQuickPointerHandler *>(o)) { - pointerHandler->setTarget(that); + Q_ASSERT(pointerHandler->parentItem() == that); + // Accept all buttons, and leave filtering to pointerEvent() and/or user JS, + // because there can be multiple handlers... + that->setAcceptedMouseButtons(Qt::AllButtons); + QQuickItemPrivate *p = QQuickItemPrivate::get(that); + p->extra.value().pointerHandlers.append(pointerHandler); } else { QQuickWindow *thisWindow = qmlobject_cast<QQuickWindow *>(o); QQuickItem *item = that; |