diff options
3 files changed, 66 insertions, 1 deletions
diff --git a/src/declarative/graphicsitems/qdeclarativeflickable.cpp b/src/declarative/graphicsitems/qdeclarativeflickable.cpp index 229d04bd7a..8b07054378 100644 --- a/src/declarative/graphicsitems/qdeclarativeflickable.cpp +++ b/src/declarative/graphicsitems/qdeclarativeflickable.cpp @@ -1582,7 +1582,7 @@ bool QDeclarativeFlickable::sendMouseEvent(QGraphicsSceneMouseEvent *event) bool QDeclarativeFlickable::sceneEventFilter(QGraphicsItem *i, QEvent *e) { Q_D(QDeclarativeFlickable); - if (!isVisible() || !d->interactive) + if (!isVisible() || !d->interactive || !isEnabled()) return QDeclarativeItem::sceneEventFilter(i, e); switch (e->type()) { case QEvent::GraphicsSceneMousePress: diff --git a/tests/auto/declarative/qdeclarativeflickable/data/disabled.qml b/tests/auto/declarative/qdeclarativeflickable/data/disabled.qml new file mode 100644 index 0000000000..ac63cd461b --- /dev/null +++ b/tests/auto/declarative/qdeclarativeflickable/data/disabled.qml @@ -0,0 +1,30 @@ +import QtQuick 1.0 + +Rectangle { + id: root + width: 100; height: 100 + property bool clicked: false + + Flickable { + objectName: "flickable" + width: 100; height: 100 + contentWidth: column.width; contentHeight: column.height + enabled: false + + Column { + id: column + Repeater { + model: 4 + Rectangle { + width: 200; height: 300; color: "blue" + MouseArea { anchors.fill: parent; onClicked: { } } + } + } + } + } + + MouseArea { + width: 100; height: 30 + onClicked: root.clicked = true + } +} diff --git a/tests/auto/declarative/qdeclarativeflickable/tst_qdeclarativeflickable.cpp b/tests/auto/declarative/qdeclarativeflickable/tst_qdeclarativeflickable.cpp index 748760a95b..c248d8cfb0 100644 --- a/tests/auto/declarative/qdeclarativeflickable/tst_qdeclarativeflickable.cpp +++ b/tests/auto/declarative/qdeclarativeflickable/tst_qdeclarativeflickable.cpp @@ -79,6 +79,7 @@ private slots: void testQtQuick11Attributes_data(); void wheel(); void flickVelocity(); + void disabled(); private: QDeclarativeEngine engine; @@ -528,6 +529,40 @@ void tst_qdeclarativeflickable::flick(QGraphicsView *canvas, const QPoint &from, QTest::mouseRelease(canvas->viewport(), Qt::LeftButton, 0, canvas->mapFromScene(to)); } +void tst_qdeclarativeflickable::disabled() +{ + QDeclarativeView *canvas = new QDeclarativeView; + canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/disabled.qml")); + canvas->show(); + canvas->setFocus(); + QVERIFY(canvas->rootObject() != 0); + + QDeclarativeFlickable *flick = canvas->rootObject()->findChild<QDeclarativeFlickable*>("flickable"); + QVERIFY(flick != 0); + + QTest::mousePress(canvas->viewport(), Qt::LeftButton, 0, canvas->mapFromScene(QPoint(50,90))); + + QMouseEvent moveEvent(QEvent::MouseMove, canvas->mapFromScene(QPoint(50, 80)), Qt::LeftButton, Qt::LeftButton,Qt::NoModifier); + QApplication::sendEvent(canvas, &moveEvent); + + moveEvent = QMouseEvent(QEvent::MouseMove, canvas->mapFromScene(QPoint(50, 70)), Qt::LeftButton, Qt::LeftButton,Qt::NoModifier); + QApplication::sendEvent(canvas, &moveEvent); + + moveEvent = QMouseEvent(QEvent::MouseMove, canvas->mapFromScene(QPoint(50, 60)), Qt::LeftButton, Qt::LeftButton,Qt::NoModifier); + QApplication::sendEvent(canvas, &moveEvent); + + QVERIFY(flick->isMoving() == false); + + QTest::mouseRelease(canvas->viewport(), Qt::LeftButton, 0, canvas->mapFromScene(QPoint(50, 60))); + + // verify that mouse clicks on other elements still work (QTBUG-20584) + QTest::mousePress(canvas->viewport(), Qt::LeftButton, 0, canvas->mapFromScene(QPoint(50, 10))); + QTest::mouseRelease(canvas->viewport(), Qt::LeftButton, 0, canvas->mapFromScene(QPoint(50, 10))); + + QVERIFY(canvas->rootObject()->property("clicked").toBool() == true); +} + + template<typename T> T *tst_qdeclarativeflickable::findItem(QGraphicsObject *parent, const QString &objectName) { |