Make the MXML report component the target of the click as a component, not children

So, I have a component based on canvas, and inside this component I have two images. I have a component for listening to a click, and when this event occurs, one image becomes transparent and the other becomes visible.

This part works great.

Now, by clicking on this component, I also want to do something with the parent canvas, I already have work for more basic types (image, canvas, text, etc.), but the problem with my component is that the event click has the internal image as the target, so what I want to do with the external canvas happens to the component canvas.

How to make my whole component a whole click on it?

3.5 SDK

+3
source share
2 answers

You can make the external component a click object by setting mouseChildren = false on the external component. Clicking anywhere on the component (including any of the subcomponents) will then set the event target to the external component. Hope this helps.

+4
source

I handled this by adding a click-through handler for children that stops the immediate distribution and then dispatches a click event from an external component. Wade's solution is much better.

0
source

Source: https://habr.com/ru/post/1787579/


All Articles