summaryrefslogtreecommitdiffstats
path: root/src/gui/kernel/qevent.cpp
diff options
context:
space:
mode:
authorShawn Rutledge <shawn.rutledge@qt.io>2020-09-14 16:13:16 +0200
committerShawn Rutledge <shawn.rutledge@qt.io>2020-09-17 19:03:24 +0200
commit153dcfbbba822390ccb7109499088cc954100a26 (patch)
tree281f214916317d321fed680428b371e8ae9910b7 /src/gui/kernel/qevent.cpp
parent55a7dd458102d63ba6c21a3a5ec7c3365653405e (diff)
Rename is[Begin|Update|End]Event, reimplement in QWheelEvent
These states correspond well with ScrollPhase, and this abstraction makes it possible to handle wheel events the same way as mouse events in Qt Quick: on "begin" we deliver to all Items and Handlers until all points (the only point) are accepted; on "update" and "end" we deliver only to the exclusive grabber, if there is one, and to any passive grabbers. Change-Id: I702dbd4f2c1bf5962eb3dbb9e4b725300a00a887 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io> Reviewed-by: Paul Wicking <paul.wicking@qt.io> Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Diffstat (limited to 'src/gui/kernel/qevent.cpp')
-rw-r--r--src/gui/kernel/qevent.cpp33
1 files changed, 29 insertions, 4 deletions
diff --git a/src/gui/kernel/qevent.cpp b/src/gui/kernel/qevent.cpp
index 6f4208fe84..5b7bf73dbf 100644
--- a/src/gui/kernel/qevent.cpp
+++ b/src/gui/kernel/qevent.cpp
@@ -906,7 +906,7 @@ QSinglePointEvent::QSinglePointEvent(QEvent::Type type, const QPointingDevice *d
/*!
Returns \c true if this event represents a \l {button()}{button} being pressed.
*/
-bool QSinglePointEvent::isPressEvent() const
+bool QSinglePointEvent::isBeginEvent() const
{
return m_button != Qt::NoButton && m_mouseState.testFlag(m_button);
}
@@ -922,7 +922,7 @@ bool QSinglePointEvent::isUpdateEvent() const
/*!
Returns \c true if this event represents a \l {button()}{button} being released.
*/
-bool QSinglePointEvent::isReleaseEvent() const
+bool QSinglePointEvent::isEndEvent() const
{
return m_button != Qt::NoButton && !m_mouseState.testFlag(m_button);
}
@@ -1503,6 +1503,31 @@ QWheelEvent::QWheelEvent(const QPointF &pos, const QPointF &globalPos, QPoint pi
QWheelEvent::~QWheelEvent()
{
}
+
+/*!
+ Returns \c true if this event's phase() is Qt::ScrollBegin.
+*/
+bool QWheelEvent::isBeginEvent() const
+{
+ return m_phase == Qt::ScrollBegin;
+}
+
+/*!
+ Returns \c true if this event's phase() is Qt::ScrollUpdate or Qt::ScrollMomentum.
+*/
+bool QWheelEvent::isUpdateEvent() const
+{
+ return m_phase == Qt::ScrollUpdate || m_phase == Qt::ScrollMomentum;
+}
+
+/*!
+ Returns \c true if this event's phase() is Qt::ScrollEnd.
+*/
+bool QWheelEvent::isEndEvent() const
+{
+ return m_phase == Qt::ScrollEnd;
+}
+
#endif // QT_CONFIG(wheelevent)
/*!
@@ -4738,7 +4763,7 @@ QTouchEvent::~QTouchEvent()
/*!
Returns true if this event includes at least one newly-pressed touchpoint.
*/
-bool QTouchEvent::isPressEvent() const
+bool QTouchEvent::isBeginEvent() const
{
return m_touchPointStates.testFlag(QEventPoint::State::Pressed);
}
@@ -4756,7 +4781,7 @@ bool QTouchEvent::isUpdateEvent() const
/*!
Returns true if this event includes at least one newly-released touchpoint.
*/
-bool QTouchEvent::isReleaseEvent() const
+bool QTouchEvent::isEndEvent() const
{
return m_touchPointStates.testFlag(QEventPoint::State::Released);
}