When I click the shared part of these two area, I think the area2 which is belower in the tree will receive the event first, so the output will always be ‘area2 is clicked’. But it seems the result is random:
“2:Left Mouse Button
1:Left Mouse Button
1:Left Mouse Button
1:Left Mouse Button
1:Left Mouse Button
1:Left Mouse Button
2:Left Mouse Button
1:Left Mouse Button
2:Left Mouse Button
2:Left Mouse Button
2:Left Mouse Button
1:Left Mouse Button
2:Left Mouse Button”
That is confused.
Visually one area2d is rendered after the other and looks like it is “on top”, but that is just a rendering order illusion, and the mechanism governing the detection is the collision system.
When two areas in the same collision layer overlap, it cannot be deterministically determined who should be picked. This is why it seems like it’s random, because it is non-deterministic.