Details
-
Task
-
Resolution: Done
-
P3: Somewhat important
-
None
-
None
-
520f9bebac742f885dc398533d91924de8793064
Description
QtQuick 2.0 MouseArea element has started propagating unhandled clicked, doubleClicked and pressAndHold mouse events to the other mouse areas below. This makes it possible to easily distribute mouse handling logic between multiple participants, but also may as well lead to unwanted coupling, hard-to-spot bugs and side-effects between overlapping mouse areas, especially when the user interaction is handled by both the application and stakeholder components application depends to. Many if not most interactive components (buttons, sliders, popups, views) don't want to see mouse events they receive leaking to components below.
Currently developer can stop propagation by implementing empty signal handlers for all the propagated events: clicks, double clicks and press&holds.
MouseArea { onClicked: {} onDoubleClicked: {} onPressAndHold: {} }
which feels a bit hacky. Adding an explicit property to handle propagation would potentially result in a more readable code and make the feature more explicitly available in MouseArea API. Also, it would be nice if the propagation was an opt-in feature. Propagation is often needed for a certain use case, thus it would make sense to only enable it when developer explicitly needs it. If propagateEvents has not been defined, Qt Quick 2.0 MouseArea would continue work as in Qt Quick 1.0 and by default block clicks, double clicks and touch&hold events.
MouseArea { id: delegate propagateEvents: true // parent known, enable propagation so that parent can handle double clicks and press&holds onClicked: { ...} }
Attachments
For Gerrit Dashboard: QTBUG-21081 | ||||||
---|---|---|---|---|---|---|
# | Subject | Branch | Project | Status | CR | V |
8834,5 | Add propagateComposedEvents property to MouseArea | master | qt/qtdeclarative | Status: MERGED | +2 | 0 |