[Qt-qml] Propagating MouseArea Events
Gregory Schlomoff
gregory.schlomoff at gmail.com
Tue Mar 15 18:37:11 CET 2011
I've already raised this issue before. See:
http://comments.gmane.org/gmane.comp.lib.qt.qml/2041 and
http://bugreports.qt.nokia.com/browse/QTBUG-13007
Basically, the accepted property is totally useless in this situation,
and doesn't complies wih it's documentation.
As far as I can tell, setting accepted to false only has effect for
double clicks. See Qt QML docs about this
(http://doc.qt.nokia.com/main-snapshot/qml-mousearea.html#onDoubleClicked-signal).
This is why you're getting clicked + doubleclick
One solution to propagate the click is do to a hit test in the mouse
area that is getting the onClick event and manually calling the
onClick handler of the other mousearea. I gave example of this in the
pages referenced above.
Cheers,
Greg
On Tue, Mar 15, 2011 at 6:33 PM, <shiv.sood at nokia.com> wrote:
> Hi There,
> Have a need to propagate MouseArea events to 2 overlapping MouseArea Elements. Expected the following code to work and pass events across 2 mouse Areas. What is see is that
>
> - "outerMouseArea" is not passing the single click event to the "innerMouseArea" though I have set the mouse.accepted = false in outerMouseArea::onClicked(). How can these Mouse Areas pass events so that innerMouseArea handles a given type of event while the outerMouseArea handles the other event.
> - Also for every doubleClick I see the onClicked() also being called. If there a way to only signal doubleClick() event and not a clicked() followed by dobuleClick()
>
> Rectangle {
> height:400
> width: 800
> color: "red"
>
> Rectangle {
> width: 360
> height: 360
> anchors.centerIn: parent
> color: "blue"
>
> Rectangle {
> width:80
> height: 100
> anchors.centerIn: parent
> color: "green"
> MouseArea {
> id: innerMouseArea
> anchors.fill: parent
> onClicked: {
> mouse.accepted = true;
> console.log ("single click accepted")
> }
> }
> }
>
> MouseArea {
> id:outerMouseArea
> anchors.fill: parent
>
> onDoubleClicked: {
> console.log ("double click accepted")
> mouse.accepted = true;
> }
>
> onClicked: {
> console.log ("pass on the single click event")
> mouse.accepted = false;
> }
> }
> }
> }
>
>
> Regards,
> Shiv
> _______________________________________________
> Qt-qml mailing list
> Qt-qml at qt.nokia.com
> http://lists.qt.nokia.com/mailman/listinfo/qt-qml
>
More information about the Qt-qml
mailing list