diff options
author | Frederik Gladhorn <frederik.gladhorn@theqtcompany.com> | 2016-07-15 13:19:22 +0200 |
---|---|---|
committer | Frederik Gladhorn <frederik.gladhorn@qt.io> | 2016-07-15 18:34:23 +0000 |
commit | 1b0a6a073e5b79121606312ac3fcfd267ba462ae (patch) | |
tree | bc7621602605e021214969a99a58a34bf432d79c /src/quick | |
parent | 288c1425d6e3ac200dd8e687f13de6ce4a41260b (diff) |
Add QQuickPointerEvent::allPointsAccepted
Convenience method to decide if the event is completely accepted or
further delivery makes sense.
Change-Id: I389a975cca2966962848203f69ec7f2e307a210a
Reviewed-by: Frederik Gladhorn <frederik.gladhorn@qt.io>
Diffstat (limited to 'src/quick')
-rw-r--r-- | src/quick/items/qquickevents.cpp | 15 | ||||
-rw-r--r-- | src/quick/items/qquickevents_p_p.h | 1 |
2 files changed, 16 insertions, 0 deletions
diff --git a/src/quick/items/qquickevents.cpp b/src/quick/items/qquickevents.cpp index 911cc9a52c..d7b1f7573b 100644 --- a/src/quick/items/qquickevents.cpp +++ b/src/quick/items/qquickevents.cpp @@ -573,6 +573,21 @@ const QQuickEventPoint *QQuickPointerEvent::point(int i) const { return nullptr; } +bool QQuickPointerEvent::allPointsAccepted() const +{ + Q_ASSERT(m_event && !isTabletEvent()); + if (isMouseEvent()) { + return m_mousePoint->isAccepted(); + } + if (isTouchEvent()) { + for (int i = 0; i < m_pointCount; ++i) { + if (!m_touchPoints.at(i)->isAccepted()) + return false; + } + } + return true; +} + /*! \internal Populate the reusable synth-mouse event from one touchpoint. diff --git a/src/quick/items/qquickevents_p_p.h b/src/quick/items/qquickevents_p_p.h index 624c131683..5dea26a2a5 100644 --- a/src/quick/items/qquickevents_p_p.h +++ b/src/quick/items/qquickevents_p_p.h @@ -338,6 +338,7 @@ public: // helpers for C++ only (during event delivery) bool isTouchEvent() const; bool isTabletEvent() const; bool isValid() const { return m_event != nullptr; } + bool allPointsAccepted() const; int pointCount() const { return m_pointCount; } const QQuickEventPoint *point(int i) const; |