summaryrefslogtreecommitdiffstats
path: root/src/gui/kernel/qevent.h
diff options
context:
space:
mode:
authorShawn Rutledge <shawn.rutledge@qt.io>2020-07-21 22:08:36 +0200
committerShawn Rutledge <shawn.rutledge@qt.io>2020-08-06 10:23:56 +0200
commit6d6ed64d6ca27c1b5fec305e6ed9b923b5bb1037 (patch)
tree1cf102bc85019cf61a6b398c6b1fae0de367759d /src/gui/kernel/qevent.h
parentb9873b7dde4042445dbb5ff3c46cea96b2dea4aa (diff)
Add QPointerEvent::is[Press|Update|Release]Event accessors
QQuickPointerEvent had them, so despite how trivial they look, it's very convenient to keep using them in QQuickWindow rather than duplicating these kinds of checks in various places, and for multiple event types too. Change-Id: I32ad8110fd2361e69de50a679ddbdb2a2db7ecee Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Diffstat (limited to 'src/gui/kernel/qevent.h')
-rw-r--r--src/gui/kernel/qevent.h12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/gui/kernel/qevent.h b/src/gui/kernel/qevent.h
index cfbaf8603e..8ba138a1bb 100644
--- a/src/gui/kernel/qevent.h
+++ b/src/gui/kernel/qevent.h
@@ -200,6 +200,9 @@ public:
virtual ~QPointerEvent();
virtual int pointCount() const = 0;
virtual const QEventPoint &point(int i) const = 0;
+ virtual bool isPressEvent() const { return false; }
+ virtual bool isUpdateEvent() const { return false; }
+ virtual bool isReleaseEvent() const { return false; }
explicit QPointerEvent(Type type, const QPointingDevice *dev, Qt::KeyboardModifiers modifiers = Qt::NoModifier);
const QPointingDevice *pointingDevice() const;
@@ -225,6 +228,10 @@ public:
inline QPointF scenePosition() const { return m_point.scenePosition(); }
inline QPointF globalPosition() const { return m_point.globalPosition(); }
+ bool isPressEvent() const override;
+ bool isUpdateEvent() const override;
+ bool isReleaseEvent() const override;
+
protected:
QEventPoint m_point;
Qt::MouseButton m_button = Qt::NoButton;
@@ -330,6 +337,8 @@ public:
inline QPointF posF() const { return position(); }
#endif // QT_DEPRECATED_SINCE(6, 0)
+ bool isUpdateEvent() const override { return true; }
+
// TODO deprecate when we figure out an actual replacement (point history?)
inline QPoint oldPos() const { return m_oldPos.toPoint(); }
inline QPointF oldPosF() const { return m_oldPos; }
@@ -954,6 +963,9 @@ public:
inline QObject *target() const { return m_target; }
inline QEventPoint::States touchPointStates() const { return m_touchPointStates; }
const QList<QEventPoint> &touchPoints() const { return m_touchPoints; }
+ bool isPressEvent() const override;
+ bool isUpdateEvent() const override;
+ bool isReleaseEvent() const override;
protected:
QObject *m_target = nullptr;