MouseArea stuck in pressed state
-
Hi,
I stumbled on a problem with the MouseArea on a Touchscreen: If you hold the MouseArea pressed while setting the visibility of the Area (or a parent) to false the MouseArea won't work anylonger (even when visible again) and any press or click is ignored, even with the mouse.
I made an little example, use it like this:
- Touch and release the orange Rectangle.
- Then quickly touch and hold the touch till the orange Rectangle is no longer visible.
- Release.
- The Rectangle now will toggle every 3secs visibility.
- But even when the "brokenMouseArea" is visible, it won't accept any new clicks or touch events. All clicks of the orange Rect are now handle by the "fallbackMouseArea". Which is wrong.
import QtQuick 2.5 import QtQuick.Window 2.0 Window { visible: true width: 640 height: 480 MouseArea { id: fallbackMouseArea anchors.fill: parent onPressedChanged: console.log("fallbackMouseArea - pressed: " + pressed ); } Rectangle { id: rect width: 100 height: 100 anchors.centerIn: parent color: "orange" MouseArea { id: brokenMouseArea anchors.fill: parent onClicked: timer.running = !timer.running onPressedChanged: console.log("brokenMouseArea - pressed: " + pressed ); } } Timer { id: timer interval: 3000 repeat: true onTriggered: rect.visible = !rect.visible onRunningChanged: console.log("running: " + running ); } }
Logging results using the Mouse:
qml: brokenMouseArea - pressed: true
qml: brokenMouseArea - pressed: false
qml: running: true
qml: brokenMouseArea - pressed: true
qml: brokenMouseArea - pressed: false
qml: brokenMouseArea - pressed: true
qml: brokenMouseArea - pressed: false
qml: running: falseNote: The MouseArea pressed state is set to false when visibility is changed to false which is correct behaviour.
Logging results using a Touchmonitor:
qml: brokenMouseArea - pressed: true
qml: brokenMouseArea - pressed: false
qml: running: true
qml: brokenMouseArea - pressed: true
qml: fallbackMouseArea - pressed: true
qml: fallbackMouseArea - pressed: false
qml: fallbackMouseArea - pressed: true
qml: fallbackMouseArea - pressed: false
qml: fallbackMouseArea - pressed: true
qml: fallbackMouseArea - pressed: false
qml: fallbackMouseArea - pressed: true
qml: fallbackMouseArea - pressed: falseNote: "qml: brokenMouseArea - pressed: false" is missing. The MouseArea is stuck in "pressed = true" and won't go back to pressed = false
-
Are you using Qt 5.8.0? I recall such bug. It was probably fixed by https://codereview.qt-project.org/#/c/186452/ so the fix would be available in Qt 5.9.0. You can already test with the lastest Qt 5.9 beta available in the online installer.