path: root/src/quick/handlers/qquickhoverhandler.cpp
diff options
authorShawn Rutledge <shawn.rutledge@qt.io>2018-08-16 11:29:29 +0200
committerShawn Rutledge <shawn.rutledge@qt.io>2019-09-19 16:13:57 +0200
commit3fb574d01c106e786f9a43ef1e0d781e156d52fa (patch)
tree4ff601c6152c20dbee98efd97f0ad72e5fc3767d /src/quick/handlers/qquickhoverhandler.cpp
parentb9ba1ed06f63053b6fe5426cc1cc726b6b85592f (diff)
HoverHandler: handle all device types; hovered=false on touch releasev5.14.0-alpha1
It doesn't make sense to show hover feedback after releasing a touchpoint just because the core pointer cursor happened to move along with the touchpoint, so we explicitly set the hovered property to false when the touchpoint is released. However the next mouse movement will set it back to true again if the mouse cursor is still inside. This is especially important for touchscreen-based haptic interfaces: any hover feedback should be shown when a finger is dragged into an interface element and hidden again when the finger is released. Change-Id: Iff7f23f089466cc0da94d2a46690719f6d70cae2 Reviewed-by: Jan Arve Sæther <jan-arve.saether@qt.io>
Diffstat (limited to 'src/quick/handlers/qquickhoverhandler.cpp')
1 files changed, 6 insertions, 5 deletions
diff --git a/src/quick/handlers/qquickhoverhandler.cpp b/src/quick/handlers/qquickhoverhandler.cpp
index a6325e084b..79cb288af8 100644
--- a/src/quick/handlers/qquickhoverhandler.cpp
+++ b/src/quick/handlers/qquickhoverhandler.cpp
@@ -1,6 +1,6 @@
-** Copyright (C) 2018 The Qt Company Ltd.
+** Copyright (C) 2019 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
** This file is part of the QtQuick module of the Qt Toolkit.
@@ -72,9 +72,6 @@ QQuickHoverHandler::QQuickHoverHandler(QQuickItem *parent)
// Tell QQuickPointerDeviceHandler::wantsPointerEvent() to ignore button state
d_func()->acceptedButtons = Qt::NoButton;
- // Rule out the touchscreen for now (can be overridden in QML in case a hover-detecting touchscreen exists)
- setAcceptedDevices(static_cast<QQuickPointerDevice::DeviceType>(
- static_cast<int>(QQuickPointerDevice::AllDevices) ^ static_cast<int>(QQuickPointerDevice::TouchScreen)));
@@ -103,7 +100,11 @@ bool QQuickHoverHandler::wantsPointerEvent(QQuickPointerEvent *event)
void QQuickHoverHandler::handleEventPoint(QQuickEventPoint *point)
- setHovered(true);
+ bool hovered = true;
+ if (point->state() == QQuickEventPoint::Released &&
+ point->pointerEvent()->device()->pointerType() == QQuickPointerDevice::Finger)
+ hovered = false;
+ setHovered(hovered);