2

I have a global MouseArea mouseAreaRoot taking the whole screen to prevents actions on specific buttons when a popup is opened.

Within the QML objects below this global MouseArea, I have a nested MouseArea nestedMenuMouseArea handling the clicks on my menu.

The problem is that when I click on the menu, the mouse events are redirected to mouseAreaRoot and not nestedMenuMouseArea. This is the behaviour one would expect, since the global MouseArea covers the entire screen.

I would like to exclude nestedMenuMouseArea from the effects of mouseAreaRoot which prevents any actions on the other QML objects.

I read about the propagateComposedEvents attribute, but it only seems to work from child to parent.

I would like the opposite: detect from mouseAreaRoot a click onto nestedMenuMouseArea and dispatch the event to it in order to trigger its onClicked code.

Grégoire Borel
  • 1,880
  • 3
  • 33
  • 55
  • 1
    please provide [Minimal, Complete, and Verifiable example](https://stackoverflow.com/help/mcve) instead of explaining your code. – folibis Jul 24 '18 at 16:09
  • 1
    As for you issue - you should set [MouseEvent.accepted](http://doc.qt.io/qt-5/qml-qtquick-mouseevent.html#accepted-prop) to false along with [propagateComposedEvents: true](http://doc.qt.io/qt-5/qml-qtquick-mousearea.html#propagateComposedEvents-prop) – folibis Jul 24 '18 at 16:18

1 Answers1

2

As no code is here, we can not find visual stacking order.

The complete mouse area events propagation is based on your visual stacking order.

If A is parent Item, B and C are A's children, D and E are C's children...

Something like:

A{
    B{}

    C{
       D{}
       E{}
     }
 }

The rough visual stacking order is (if Z value is not exclusively specified),

E D C B A.

So the mouse area event propagation, starts from E and reaches to A.

Unless some where mouse area's enabled property is exclusively set to false.

So first and most important thing you have to look for is.... How your QML parent- children are arranged.

And next is check if enabled is false for the mouse area.

and next like "folibs" said in comment,ensure you set MouseEvent.accepted to false along with propagateComposedEvents: true

Pavan Chandaka
  • 11,671
  • 5
  • 26
  • 34