diff options
author | Shawn Rutledge <shawn.rutledge@qt.io> | 2016-08-15 14:14:07 +0200 |
---|---|---|
committer | Shawn Rutledge <shawn.rutledge@qt.io> | 2016-08-23 14:47:35 +0000 |
commit | a0cb20c08db13003f7b8adc2f02fdcadf96fb8d1 (patch) | |
tree | 8a700b0018a741a3290de9a8d3f71cd6cf956cc0 /src/quick/handlers/qquickpointerhandler.cpp | |
parent | ad96378ba27d5a89cf447d912cdb8ae6cd6c34ec (diff) |
add QQuickPointerHandler::wantsPointerEvent
There will be an inheritance hierarchy of pointer handlers. The base
class doesn't have enough information to know whether an event should
be accepted or rejected, so it cannot change the state of the event,
so there's no way for a subclass to benefit from the base class's
checking of m_enabled, if it has no way to communicate to the
subclasses. An intermediate class has more information which
contributes to the decision of whether to accept or reject, but still
not enough: the leaf class must make the final decision. So we need a
virtual bool function, at least as an implementation detail, even
though from the perspective of event delivery, there's only one
outcome: the event is accepted, or not. We have eschewed public bool
functions to avoid ambiguity during delivery: there is no return
value to pay attention to, only the accepted state of the event.
Change-Id: Ieaca4968fce0064f80b5460aa4c10b431036e12a
Reviewed-by: Jan Arve Sæther <jan-arve.saether@theqtcompany.com>
Diffstat (limited to 'src/quick/handlers/qquickpointerhandler.cpp')
-rw-r--r-- | src/quick/handlers/qquickpointerhandler.cpp | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/src/quick/handlers/qquickpointerhandler.cpp b/src/quick/handlers/qquickpointerhandler.cpp index c0815a5a27..293eae914e 100644 --- a/src/quick/handlers/qquickpointerhandler.cpp +++ b/src/quick/handlers/qquickpointerhandler.cpp @@ -122,10 +122,20 @@ void QQuickPointerHandler::setTarget(QQuickItem *target) emit targetChanged(); } +void QQuickPointerHandler::handlePointerEvent(QQuickPointerEvent *event) +{ + if (wantsPointerEvent(event)) + handlePointerEventImpl(event); +} + +bool QQuickPointerHandler::wantsPointerEvent(QQuickPointerEvent *event) +{ + Q_UNUSED(event) + return m_enabled; +} + void QQuickPointerHandler::handlePointerEventImpl(QQuickPointerEvent *event) { - if (!m_enabled) - return; m_currentEvent = event; } |