From 12c315f34ca428c3da38716d2c071a8e94f2acf0 Mon Sep 17 00:00:00 2001 From: "Bradley T. Hughes" Date: Fri, 5 Jun 2009 14:26:22 +0200 Subject: Accept TouchBegin events by default if they are enabled After an API review round, we agreed that it makes sense for the TouchBegin event to default to accepted if the widget has subscribed to receive touch events. --- examples/multitouch/fingerpaint/scribblearea.cpp | 8 +++----- examples/multitouch/knobs/knob.cpp | 4 ---- examples/multitouch/pinchzoom/graphicsview.cpp | 1 - src/gui/graphicsview/qgraphicsscene.cpp | 6 +++--- src/gui/kernel/qapplication.cpp | 8 ++++---- 5 files changed, 10 insertions(+), 17 deletions(-) diff --git a/examples/multitouch/fingerpaint/scribblearea.cpp b/examples/multitouch/fingerpaint/scribblearea.cpp index ffff9bb..71fbd19 100644 --- a/examples/multitouch/fingerpaint/scribblearea.cpp +++ b/examples/multitouch/fingerpaint/scribblearea.cpp @@ -206,12 +206,10 @@ bool ScribbleArea::event(QEvent *event) break; } } - - event->accept(); - return true; + break; } default: - break; + return QWidget::event(event); } - return QWidget::event(event); + return true; } diff --git a/examples/multitouch/knobs/knob.cpp b/examples/multitouch/knobs/knob.cpp index b7cc6f3..bced73c 100644 --- a/examples/multitouch/knobs/knob.cpp +++ b/examples/multitouch/knobs/knob.cpp @@ -63,9 +63,6 @@ bool Knob::sceneEvent(QEvent *event) { switch (event->type()) { case QEvent::GraphicsSceneTouchBegin: - event->accept(); - break; - case QEvent::GraphicsSceneTouchUpdate: case QEvent::GraphicsSceneTouchEnd: { @@ -81,7 +78,6 @@ bool Knob::sceneEvent(QEvent *event) rotate(line2.angleTo(line1)); } - touchEvent->accept(); break; } diff --git a/examples/multitouch/pinchzoom/graphicsview.cpp b/examples/multitouch/pinchzoom/graphicsview.cpp index f763e6f..0856639 100644 --- a/examples/multitouch/pinchzoom/graphicsview.cpp +++ b/examples/multitouch/pinchzoom/graphicsview.cpp @@ -71,7 +71,6 @@ bool GraphicsView::event(QEvent *event) / QLineF(touchPoint0->startPos(), touchPoint1->startPos()).length(); setTransform(QTransform().scale(scaleFactor, scaleFactor)); } - event->accept(); return true; } default: diff --git a/src/gui/graphicsview/qgraphicsscene.cpp b/src/gui/graphicsview/qgraphicsscene.cpp index c0b371f..bf8d83d 100644 --- a/src/gui/graphicsview/qgraphicsscene.cpp +++ b/src/gui/graphicsview/qgraphicsscene.cpp @@ -5876,9 +5876,9 @@ bool QGraphicsScenePrivate::sendTouchBeginEvent(QGraphicsItem *origin, QGraphics foreach (QGraphicsItem *item, cachedItemsUnderMouse) { // first, try to deliver the touch event updateTouchPointsForItem(item, touchEvent); - touchEvent->ignore(); - res = item->acceptTouchEvents() - && sendEvent(item, touchEvent); + bool acceptTouchEvents = item->acceptTouchEvents(); + touchEvent->setAccepted(acceptTouchEvents); + res = acceptTouchEvents && sendEvent(item, touchEvent); eventAccepted = touchEvent->isAccepted(); item->d_ptr->acceptedTouchBeginEvent = (res && eventAccepted); touchEvent->spont = false; diff --git a/src/gui/kernel/qapplication.cpp b/src/gui/kernel/qapplication.cpp index 3c9d2a8..ca0054f 100644 --- a/src/gui/kernel/qapplication.cpp +++ b/src/gui/kernel/qapplication.cpp @@ -4037,7 +4037,7 @@ bool QApplication::notify(QObject *receiver, QEvent *e) break; #endif case QEvent::TouchBegin: - // Note: TouchUpdate and TouchEnd events are sent to d->currentMultitouchWidget and never propagated + // Note: TouchUpdate and TouchEnd events are never propagated { QWidget *widget = static_cast(receiver); QTouchEvent *touchEvent = static_cast(e); @@ -4051,9 +4051,9 @@ bool QApplication::notify(QObject *receiver, QEvent *e) while (widget) { // first, try to deliver the touch event - touchEvent->ignore(); - res = widget->testAttribute(Qt::WA_AcceptTouchEvents) - && d->notify_helper(widget, touchEvent); + bool acceptTouchEvents = widget->testAttribute(Qt::WA_AcceptTouchEvents); + touchEvent->setAccepted(acceptTouchEvents); + res = acceptTouchEvents && d->notify_helper(widget, touchEvent); eventAccepted = touchEvent->isAccepted(); widget->setAttribute(Qt::WA_AcceptedTouchBeginEvent, res && eventAccepted); touchEvent->spont = false; -- cgit v0.12