Details
-
Bug
-
Resolution: Incomplete
-
P3: Somewhat important
-
None
-
5.13.1
-
None
-
Dell XPS 15 9560, Windows 10
Description
I created a small example to show the problem:
#include "UiHelper.h" #include <QCoreApplication> #include <QDebug> UiHelper::UiHelper(QObject* parent) : QObject(parent) {} void UiHelper::ungrabMouseAndTouchPoints(QQuickItem* item, bool recursive) const { if (item != nullptr) { qDebug() << "Ungrab:" << item << item->objectName(); item->ungrabMouse(); item->ungrabTouchPoints(); if (recursive) { for (auto* child : item->childItems()) { this->ungrabMouseAndTouchPoints(child, recursive); } } } }
import QtQuick 2.12 import QtQuick.Controls 2.5 import QtQuick.Layouts 1.3 import Ui 1.0 ApplicationWindow { visible: true width: 640 height: 480 ColumnLayout { anchors.centerIn: parent Button { id: button text: "Button" background: Rectangle { color: button.pressed ? "orange" : "lightGrey" } } MouseArea { id: mouseArea implicitWidth: 200 implicitHeight: 100 Rectangle { anchors.fill: parent color: mouseArea.pressed ? "orange" : "lightGrey" Label { anchors.centerIn: parent text: "MouseArea" } } } Item { id: tapHandlerContainer implicitWidth: 200 implicitHeight: 100 Rectangle { anchors.fill: parent color: tapHandler.pressed ? "orange" : "lightGrey" Label { anchors.centerIn: parent text: "TapHandler" } } TapHandler { id: tapHandler gesturePolicy: TapHandler.ReleaseWithinBounds } } } Timer { running: true interval: 4000 repeat: true onTriggered: { UiHelper.ungrabMouseAndTouchPoints(button, false); UiHelper.ungrabMouseAndTouchPoints(mouseArea, false); UiHelper.ungrabMouseAndTouchPoints(tapHandlerContainer, false); console.debug("----"); } } }
To reproduce the problem press and hold Button or MouseArea or TapHandler.
At a constant interval, the timer tries to take the grab from these items.
This, however, does not work for parent of TapHandler.
In my opinion, it makes sense for all Input Handlers to stop grabbing if these methods were called on their parent Item.
Otherwise, it is for example not possible to cancel a gesture. (see https://bugreports.qt.io/browse/QTBUG-78248)
Attachments
Issue Links
- relates to
-
QTBUG-124777 QQuickTapHandler::setPressed() assumes non-null event if not canceled
-
- Open
-