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:

    1. Touch and release the orange Rectangle.
    2. Then quickly touch and hold the touch till the orange Rectangle is no longer visible.
    3. Release.
    4. The Rectangle now will toggle every 3secs visibility.
    5. 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: false

    Note: 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: false

    Note: "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.



  • Thanks for your input jpnurmi!

    Yes I'm using 5.8 and 5.9 beta is fixing this issue! Thanks for pointing it out! For some reason I didn't find this bug!

    Best,
    nx


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.