Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

Pressed mouse buttons



  • Hello,

    Is there a way to find out pressed mouse buttons when the mouse cursor enter to a mouse area and when the button was clicked not under this mouse area? mouse.buttons and mouseArea.pressedButtons don't show information about pressed buttons.

    Thanks a lot,
    Maxim



  • Hi,

    @
    import QtQuick 2.0

    Rectangle {
    width: 360
    height: 360

    color: "blue"
    
    Rectangle {
        width: 100
        height: 100
    
        anchors.centerIn: parent
    
        color: "red"
    
        Text {
    
            anchors.centerIn: parent
        }
    
        MouseArea {
            id: mouse
    
            anchors.fill: parent
    
            onClicked: {
                console.log("clicked red")
            }
        }
    }
    
    MouseArea {
        anchors.fill: parent
        propagateComposedEvents: true
        onClicked: {
            mouse.accepted = false
        }
    }
    

    }
    @



  • tip: use a

    @
    console.log("clicked blue")
    @

    in the last Mousarea too to get even more feedback from this setup.


Log in to reply