[Qt-qml] Mouse Event Filtering in QML 2

michael.brasser at nokia.com michael.brasser at nokia.com
Fri Jun 10 02:02:45 CEST 2011


On 07/06/2011, at 10:51 AM, ext Alan Alpert wrote:

> On Tue, 7 Jun 2011 01:23:51 Cunha Leo (Nokia-MP-Qt/Oslo) wrote:
>> hi,
>> 
>> in qml1 I used to have an empty MouseArea{ enabled: animation.running } to
>> filter events while an animation was ongoing.
>> 
>> in qml2 this empty mouse area is no longer accepting the events by default,
>> so the only way I found was to declare empty handlers for all mouse
>> events.
>> 
>> is there a better way to achieve mouse events filtering in qml2 ?
>> 
>> cheers,
>> // leo
> 
> Currently you do need to declare empty handlers, due to changes in mouse event 
> propagation, but this is clearly not ideal. I don't think the empty mouse area 
> was that great either though. Do you have any suggestions on the best way to 
> accomplish this?


What about a convenience MouseBlocker element? e.g. something like:

//MouseBlocker.qml
import QtQuick 2.0
MouseArea {
    onPressed: {}
    onClicked: {}
    onPressAndHold: {}
    onDoubleClicked: {}
}

Regards,
Michael


More information about the Qt-qml mailing list