aboutsummaryrefslogtreecommitdiffstats
path: root/src/quick
diff options
context:
space:
mode:
authorShawn Rutledge <shawn.rutledge@qt.io>2018-05-16 13:05:23 +0200
committerShawn Rutledge <shawn.rutledge@qt.io>2018-05-18 15:12:39 +0000
commit412bedc70b32b09f4bb91a3a0503d46d19f2481a (patch)
treed9422efad1361f138c6d912dbff2edbdca0bc4e4 /src/quick
parent52d35526f256bf4c8155f5e660a214ab8a2efbdf (diff)
Add QQuickHandlerPoint::modifiers property
The event includes it; this exposes it to QML, for the benefit of conditional JS logic in Pointer Handler use cases. Task-number: QTBUG-68101 Change-Id: I3f04c5db7f5aef461edb6168922b70e3fb3bda37 Reviewed-by: Jan Arve Sæther <jan-arve.saether@qt.io>
Diffstat (limited to 'src/quick')
-rw-r--r--src/quick/handlers/qquickhandlerpoint.cpp14
-rw-r--r--src/quick/handlers/qquickhandlerpoint_p.h3
2 files changed, 17 insertions, 0 deletions
diff --git a/src/quick/handlers/qquickhandlerpoint.cpp b/src/quick/handlers/qquickhandlerpoint.cpp
index 6c7bf2fc8a..b40164d3ec 100644
--- a/src/quick/handlers/qquickhandlerpoint.cpp
+++ b/src/quick/handlers/qquickhandlerpoint.cpp
@@ -92,6 +92,7 @@ void QQuickHandlerPoint::reset()
m_pressure = 0;
m_ellipseDiameters = QSizeF();
m_pressedButtons = Qt::NoButton;
+ m_pressedModifiers = Qt::NoModifier;
}
void QQuickHandlerPoint::reset(const QQuickEventPoint *point)
@@ -111,6 +112,7 @@ void QQuickHandlerPoint::reset(const QQuickEventPoint *point)
m_pressedButtons = event->buttons();
break;
}
+ m_pressedModifiers = event->modifiers();
if (event->asPointerTouchEvent()) {
const QQuickEventTouchPoint *tp = static_cast<const QQuickEventTouchPoint *>(point);
m_uniqueId = tp->uniqueId();
@@ -164,6 +166,7 @@ void QQuickHandlerPoint::reset(const QVector<QQuickEventPoint *> &points)
m_id = 0;
m_uniqueId = QPointingDeviceUniqueId();
m_pressedButtons = event->buttons();
+ m_pressedModifiers = event->modifiers();
m_position = posSum / points.size();
m_scenePosition = scenePosSum / points.size();
if (press) {
@@ -273,6 +276,17 @@ void QQuickHandlerPoint::reset(const QVector<QQuickEventPoint *> &points)
/*!
\readonly
+ \qmlproperty enum QtQuick::HandlerPoint::modifiers
+ \brief Which modifier keys are currently pressed
+
+ This property holds the keyboard modifiers that were pressed at the time
+ the event occurred.
+
+ \sa MouseArea::modifiers
+*/
+
+/*!
+ \readonly
\qmlproperty QVector2D QtQuick::HandlerPoint::velocity
\brief A vector representing the average speed and direction of movement
diff --git a/src/quick/handlers/qquickhandlerpoint_p.h b/src/quick/handlers/qquickhandlerpoint_p.h
index bdf7ae0d9d..1dff52942a 100644
--- a/src/quick/handlers/qquickhandlerpoint_p.h
+++ b/src/quick/handlers/qquickhandlerpoint_p.h
@@ -68,6 +68,7 @@ class Q_QUICK_PRIVATE_EXPORT QQuickHandlerPoint {
Q_PROPERTY(QPointF scenePressPosition READ scenePressPosition)
Q_PROPERTY(QPointF sceneGrabPosition READ sceneGrabPosition)
Q_PROPERTY(Qt::MouseButtons pressedButtons READ pressedButtons)
+ Q_PROPERTY(Qt::KeyboardModifiers modifiers READ modifiers)
Q_PROPERTY(QVector2D velocity READ velocity)
Q_PROPERTY(qreal rotation READ rotation)
Q_PROPERTY(qreal pressure READ pressure)
@@ -78,6 +79,7 @@ public:
int id() const { return m_id; }
Qt::MouseButtons pressedButtons() const { return m_pressedButtons; }
+ Qt::KeyboardModifiers modifiers() const { return m_pressedModifiers; }
QPointF pressPosition() const { return m_pressPosition; }
QPointF scenePressPosition() const { return m_scenePressPosition; }
QPointF sceneGrabPosition() const { return m_sceneGrabPosition; }
@@ -97,6 +99,7 @@ private:
int m_id;
QPointingDeviceUniqueId m_uniqueId;
Qt::MouseButtons m_pressedButtons;
+ Qt::KeyboardModifiers m_pressedModifiers;
QPointF m_position;
QPointF m_scenePosition;
QPointF m_pressPosition;