I am having a Mouse Area, which should behave differently, depending on whether modifier keys are pressed. There should also be a default behaviour, when no modifier key is pressed. I test for this like this:
MouseArea {
anchors.fill: parent
acceptedButtons: Qt.LeftButton
onPressed: {
console.log('Entered onPressed: ', mouse.modifiers&Qt.NoModifier)
if(mouse.modifiers & Qt.NoModifier) {
console.log('Entered If: ', mouse.modifiers&Qt.NoModifier)
}
}
When I then press the mouse button in the MouseArea I get the following output:
qml: Entered onPressed: 0
But the second line is not printed. The problem seems to be that mouse.modifiers&Qt.NoModifier is evaluated to zero. In Contrast,
if(mouse.modifiers & Qt.ControlModifier) {
console.log("Entered Control if: ",mouse.modifiers&Qt.ControlModifier)
}
is working and prints qml: Entered Control if: 67108864
Shouldn't mouse.modifiers&Qt.NoModifier also get evaluated to something non zero?