From 3fb574d01c106e786f9a43ef1e0d781e156d52fa Mon Sep 17 00:00:00 2001 From: Shawn Rutledge Date: Thu, 16 Aug 2018 11:29:29 +0200 Subject: HoverHandler: handle all device types; hovered=false on touch release MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- src/quick/handlers/qquickhoverhandler.cpp | 11 ++++++----- 1 file 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( - static_cast(QQuickPointerDevice::AllDevices) ^ static_cast(QQuickPointerDevice::TouchScreen))); } QQuickHoverHandler::~QQuickHoverHandler() @@ -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); setPassiveGrab(point); } -- cgit v1.2.3