Unsolved MouseArea not getting released event when occluded
-
Hi,
I have a MouseArea whose
OnPressed
method triggers a chain of events, which eventually leads to the creation an object which masks the mouseArea (that is, the created object is "between" the cursor and the mouseArea, depthwise).The problem is that the release event of the mouse will not be propagated back to the mouseArea, hence any further mouse press and mouse move will not behave correctly, as the
pressed
flag will not be reset to falseAfter some interactions, the user can move or delete the created top object, which will make the mouseArea available for events again, but since the
pressed
flag is still on, any further mouse click will not produce any effect.Is this a bug? How can I workaround this?
I tried sending areleased()
event from theOnPressed
function of the mouseArea, but couldn't figure out how to create a fake mouse event (since the fields seem to be read-only...). Passing the mouse event received by theOnPressed
doesn't work (probably because the button is still set). Thecancelled()
event doesn't cut it either. -
Hi @alcinos , if you give some sample code,it would help us to understand better and get to know what you want and where it is failing.
Here is a sample code from what i have understood:-
There are 2 Rectangles rect1 and rect2, rect2 is not visible,on pressing rect1 a timer is started which on triggered will make the rect2 visible and on releasing the mouse,you will get a console print that is "Rect1 Released"``` Timer { id: dummyTimer interval: 2000 running: false onTriggered: { console.log("Timer Triggered") rect2.visible = true } } Rectangle { id: rect1 height: 100 width: 100 color: "red" anchors.centerIn: parent MouseArea { anchors.fill: parent onPressed: { console.log("Rect 1 Pressed") dummyTimer.start() } onReleased: { console.log("Rect 1 Released") } } } Rectangle { id: rect2 height: 100 width: 100 color: "green" anchors.centerIn: parent visible: false }