summaryrefslogtreecommitdiffstats
path: root/src/gui/kernel/qevent.cpp
diff options
context:
space:
mode:
authorJ-P Nurmi <jpnurmi@digia.com>2013-08-05 13:34:33 +0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-08-08 15:09:40 +0200
commit9dfe4b0e683d706400a2e929a8de97df64ca172e (patch)
treebbcd8ce3e6a9ffdffeef0be9a6e9d35dd7412e79 /src/gui/kernel/qevent.cpp
parentd916ed12b3ce36fce04f107751423f9986be52f0 (diff)
Introduce QWheelEvent::Phase (Begin, Changed, Ended)
Some platforms (read: OS X) send wheel events without delta to indicate that scrolling is about to start or has ended. Currently, Qt simply ignores wheel events that have no delta. This change introduces a new QWheelEvent attribute that specifies the phase, and makes it possible to receive the special wheel events in started/ended phases. These events are required for implementing correctly behaving transient scrollbars. Change-Id: Ib8ce0d9ce9be63b2ad60aa7b0aaa1f12ef6cad09 Reviewed-by: Gabriel de Dietrich <gabriel.dedietrich@digia.com> Reviewed-by: Shawn Rutledge <shawn.rutledge@digia.com>
Diffstat (limited to 'src/gui/kernel/qevent.cpp')
-rw-r--r--src/gui/kernel/qevent.cpp56
1 files changed, 55 insertions, 1 deletions
diff --git a/src/gui/kernel/qevent.cpp b/src/gui/kernel/qevent.cpp
index fa289bbf8b..49cc411c4f 100644
--- a/src/gui/kernel/qevent.cpp
+++ b/src/gui/kernel/qevent.cpp
@@ -654,6 +654,9 @@ QWheelEvent::QWheelEvent(const QPointF &pos, const QPointF& globalPos, int delta
event data: \a qt4Delta specifies the rotation, and \a qt4Orientation the
direction.
+ The phase() is initialized to QWheelEvent::Changed. Use the other constructor
+ to specify the phase explicitly.
+
\sa posF(), globalPosF(), angleDelta(), pixelDelta()
*/
@@ -661,9 +664,38 @@ QWheelEvent::QWheelEvent(const QPointF &pos, const QPointF& globalPos,
QPoint pixelDelta, QPoint angleDelta, int qt4Delta, Qt::Orientation qt4Orientation,
Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers)
: QInputEvent(Wheel, modifiers), p(pos), g(globalPos), pixelD(pixelDelta),
- angleD(angleDelta), qt4D(qt4Delta), qt4O(qt4Orientation), mouseState(buttons)
+ angleD(angleDelta), qt4D(qt4Delta), qt4O(qt4Orientation), mouseState(buttons), ph(Changed)
{}
+/*!
+ Constructs a wheel event object.
+
+ The \a pos provides the location of the mouse cursor
+ within the window. The position in global coordinates is specified
+ by \a globalPos.
+
+ \a pixelDelta contains the scrolling distance in pixels on screen, while
+ \a angleDelta contains the wheel rotation distance. \a pixelDelta is
+ optional and can be null.
+
+ The mouse and keyboard states at the time of the event are specified by
+ \a buttons and \a modifiers.
+
+ For backwards compatibility, the event can also hold monodirectional wheel
+ event data: \a qt4Delta specifies the rotation, and \a qt4Orientation the
+ direction.
+
+ The phase of the event is specified by \a phase.
+
+ \sa posF(), globalPosF(), angleDelta(), pixelDelta(), phase()
+*/
+
+QWheelEvent::QWheelEvent(const QPointF &pos, const QPointF& globalPos,
+ QPoint pixelDelta, QPoint angleDelta, int qt4Delta, Qt::Orientation qt4Orientation,
+ Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers, Phase phase)
+ : QInputEvent(Wheel, modifiers), p(pos), g(globalPos), pixelD(pixelDelta),
+ angleD(angleDelta), qt4D(qt4Delta), qt4O(qt4Orientation), mouseState(buttons), ph(phase)
+{}
#endif // QT_NO_WHEELEVENT
@@ -794,6 +826,28 @@ QWheelEvent::QWheelEvent(const QPointF &pos, const QPointF& globalPos,
\sa posF()
*/
+/*!
+ \enum QWheelEvent::Phase
+ \since 5.2
+
+ This enum describes the phase of a wheel event.
+
+ \value Started Scrolling has started, but the scrolling
+ distance did not yet change.
+
+ \value Changed The scrolling distance has changed (default).
+
+ \value Ended Scrolling has ended, but the scrolling distance
+ did not change anymore.
+*/
+
+/*!
+ \fn QWheelEvent::Phase QWheelEvent::phase() const
+ \since 5.2
+
+ Returns the phase of this wheel event.
+*/
+
/*!
\class QKeyEvent