Qt 5.2 RC1 MouseArea not working with PinchArea
-
If I add a PinchArea after a MouseArea then the MouseArea stops responding. This used to work fine in 5.1.1. Before I create a bug report, is this designed behavior? Am I missing something?
-
Please define "after" more clearly. Are they placed in your file like this:
@
MouseArea {}
PinchArea {}
@and anchored to fill the parent, or like that:
@
MouseArea {
PinchArea {}
}
@In any case, if it used to work and now it does not, it's likely to be a regression. Please "file a bug report":https://qt-project.org/wiki/ReportingBugsInQt if there is none reported for this already. I don't feel it's likely to be considered important enough for fixing before Qt 5.2 comes out, but maybe it will make it into 5.2.1.
-
I tried a number of things: one embedded in the other, one befor the other, etc. In every case, whichever one is deamed on top gets the input and the other doesn't work at all.
Perhaps there's a better way to handle input in a cross-platform way? If not then this seems like a pretty severe limitation.
-
OK, let's try this: in whichever component is the topmost one, add this line to your event handler:
@
// for example, in onClicked:
accepted = false;
@ -
I get 'Error: Invalid write to global property "accepted"'.
-
You've probably put it in a wrong place. You need to put it in a slot you are using in your MouseArea, which has an input MouseEvent. For example:
@
MouseArea {
/// some code
onClicked: {
// some logic
accepted = false;
}
}
@ -
Here's where I tried it:
@MouseArea {
// . . .
onPressed: {
// . . .
accepted = false;
}
onPositionChanged: {
// . . .
accepted = false;
}
}@Also here:
@PinchArea {
// . . .
onPinchStarted: {
// . . .
accepted = false;
}
onPinchUpdated: {
// . . .
accepted = false;
}
}@In both cases I get that error message.
-
OK, if I do this then the MouseArea works and the PinchArea does not:
@PinchArea {
anchors.fill: parentonPinchStarted: {
// . . .
}
onPinchUpdated: {
// . . .
}
}MouseArea {
anchors.fill: parentonPressed: {
// . . .
}
onPositionChanged: {
// . . .
}
}@If I do this then the PinchArea works and the MouseArea does not:
@PinchArea {
anchors.fill: parentonPinchStarted: {
// . . .
}
onPinchUpdated: {
// . . .
}
}MouseArea {
anchors.fill: parentonPressed: {
// . . .
mouse.accepted = false;
}
onPositionChanged: {
// . . .
mouse.accepted = false;
}
}@ -
Then maybe it is indeed a bug :)
-
Is there a better way to do panning/zooming?
-
It works if MouseArea is embedded in the PinchArea except for onWheel on desktop.