Mouse events for rectangles within a flickable
-
Hi
In my QML app, I have a Flickable containing several Rectangles, each of which has a MouseArea filling the whole Rectangle. These Rectangles are serving as buttons, so they move into a "pressed" state on the onPressed event of the MouseArea, and back to "unpressed" on the onReleased event.
The problem is that if the user presses a button, doesn't release it, and starts flicking, the onReleased event is never fired and my button remains in the "pressed" state.
I guess this is intended behaviour, because we don't want the button doing its "click" action when only a flick has occurred.
What's the best way of working round this?
-
Hi,
There is an "onCanceled handler":http://doc.qt.nokia.com/4.7-snapshot/qml-mousearea.html#onCanceled-signal that was added for this very reason :-) You could also consider binding the state's when clause to mouseArea.pressed -- it will turn to false when flicked.
Regards,
Michael -
Thanks, really helped.