How to capture mouse click on top sprite?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By derekjwhitten

I have a scene structured as follows:

- Tileset
-- YSort
--- Node2D_1
---- Area2D with CollisionShape2D
--- Node2D_2
---- Area2D with CollisionShape2D

I’m using _on_Area2D_input_event(…) to capture mouse clicks, however when there are multiple Node2D stacked on top of each other (ie same position) the event is triggering on the node which was created first. In this example Node2D_1, despite the fact that Node2D_2 has a higher z-index.

How can I get the input to trigger on the top most (highest z-index) node?