if (!mouseGrabberItem &&
event->type() == QEvent::MouseButtonPress &&
(event->button() & event->buttons()) == event->buttons()) {
- return deliverInitialMousePressEvent(rootItem, event);
+ if (deliverInitialMousePressEvent(rootItem, event))
+ event->accept();
+ else
+ event->ignore();
+ return event->isAccepted();
}
if (mouseGrabberItem) {
void focusObject();
+ void ignoreUnhandledMouseEvents();
+
private:
QTouchDevice *touchDevice;
};
delete canvas;
}
+void tst_qquickcanvas::ignoreUnhandledMouseEvents()
+{
+ QQuickCanvas* canvas = new QQuickCanvas;
+ canvas->resize(100, 100);
+ canvas->show();
+
+ QQuickItem* item = new QQuickItem;
+ item->setSize(QSizeF(100, 100));
+ item->setParentItem(canvas->rootItem());
+
+ {
+ QMouseEvent me(QEvent::MouseButtonPress, QPointF(50, 50), Qt::LeftButton, Qt::LeftButton,
+ Qt::NoModifier);
+ me.setAccepted(true);
+ QVERIFY(QCoreApplication::sendEvent(canvas, &me));
+ QVERIFY(!me.isAccepted());
+ }
+
+ {
+ QMouseEvent me(QEvent::MouseMove, QPointF(51, 51), Qt::LeftButton, Qt::LeftButton,
+ Qt::NoModifier);
+ me.setAccepted(true);
+ QVERIFY(QCoreApplication::sendEvent(canvas, &me));
+ QVERIFY(!me.isAccepted());
+ }
+
+ {
+ QMouseEvent me(QEvent::MouseButtonRelease, QPointF(51, 51), Qt::LeftButton, Qt::LeftButton,
+ Qt::NoModifier);
+ me.setAccepted(true);
+ QVERIFY(QCoreApplication::sendEvent(canvas, &me));
+ QVERIFY(!me.isAccepted());
+ }
+
+ delete canvas;
+}
+
QTEST_MAIN(tst_qquickcanvas)
#include "tst_qquickcanvas.moc"