A disabled Flickable should not filter children.
Change-Id: I9f0d8fbfd0922b5c6a9eaffa69212867359f79e0
Fixes: QTBUG-20584
Reviewed-on: http://codereview.qt.nokia.com/2354
Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com>
Reviewed-by: Bea Lam <bea.lam@nokia.com>
bool QSGFlickable::childMouseEventFilter(QSGItem *i, QEvent *e)
{
Q_D(QSGFlickable);
- if (!isVisible() || !d->interactive)
+ if (!isVisible() || !d->interactive || !isEnabled())
return QSGItem::childMouseEventFilter(i, e);
switch (e->type()) {
case QEvent::GraphicsSceneMousePress:
bool QDeclarative1Flickable::sceneEventFilter(QGraphicsItem *i, QEvent *e)
{
Q_D(QDeclarative1Flickable);
- if (!isVisible() || !d->interactive)
+ if (!isVisible() || !d->interactive || !isEnabled())
return QDeclarativeItem::sceneEventFilter(i, e);
switch (e->type()) {
case QEvent::GraphicsSceneMousePress:
--- /dev/null
+import QtQuick 2.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
+ }
+}
void returnToBounds();
void wheel();
void movingAndDragging();
+ void disabled();
private:
QDeclarativeEngine engine;
delete canvas;
}
+void tst_qsgflickable::disabled()
+{
+ QSGView *canvas = new QSGView;
+ canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/disabled.qml"));
+ canvas->show();
+ canvas->setFocus();
+ QVERIFY(canvas->rootObject() != 0);
+
+ QSGFlickable *flick = canvas->rootObject()->findChild<QSGFlickable*>("flickable");
+ QVERIFY(flick != 0);
+
+ QTest::mousePress(canvas, Qt::LeftButton, 0, QPoint(50, 90));
+
+ QMouseEvent moveEvent(QEvent::MouseMove, QPoint(50, 80), Qt::LeftButton, Qt::LeftButton, 0);
+ QApplication::sendEvent(canvas, &moveEvent);
+
+ moveEvent = QMouseEvent(QEvent::MouseMove, QPoint(50, 70), Qt::LeftButton, Qt::LeftButton, 0);
+ QApplication::sendEvent(canvas, &moveEvent);
+
+ moveEvent = QMouseEvent(QEvent::MouseMove, QPoint(50, 60), Qt::LeftButton, Qt::LeftButton, 0);
+ QApplication::sendEvent(canvas, &moveEvent);
+
+ QVERIFY(flick->isMoving() == false);
+
+ QTest::mouseRelease(canvas, Qt::LeftButton, 0, QPoint(50, 60));
+
+ // verify that mouse clicks on other elements still work (QTBUG-20584)
+ QTest::mousePress(canvas, Qt::LeftButton, 0, QPoint(50, 10));
+ QTest::mouseRelease(canvas, Qt::LeftButton, 0, QPoint(50, 10));
+
+ QVERIFY(canvas->rootObject()->property("clicked").toBool() == true);
+}
+
template<typename T>
T *tst_qsgflickable::findItem(QSGItem *parent, const QString &objectName)
{
--- /dev/null
+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
+ }
+}
void testQtQuick11Attributes();
void testQtQuick11Attributes_data();
void wheel();
+ void disabled();
private:
QDeclarativeEngine engine;
delete canvas;
}
+void tst_qdeclarativeflickable::disabled()
+{
+ QDeclarativeView *canvas = new QDeclarativeView;
+ canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/disabled.qml"));
+ canvas->show();
+ canvas->setFocus();
+ QVERIFY(canvas->rootObject() != 0);
+
+ QDeclarative1Flickable *flick = canvas->rootObject()->findChild<QDeclarative1Flickable*>("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)