How to use input_event of Area2D?

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

Area2D is set to pickable, signal is connected, yet it never receives any event (handler is never called).

Scene hierarchy: root -> Node2D -> CanvasLayer -> ColorRect -> CenterContainer -> MarginContainer -> Panel -> Panel

Button in a same container (last Panel) works, so I guess nothing else is eating events?

Docs are not helpful at all:

If no one wanted the event so far, and a Camera is assigned to the Viewport, a ray to the physics world (in the ray direction from the click) will be cast. If this ray hits an object, it will call the CollisionObject._input_event() function in the relevant physics object (bodies receive this callback by default, but areas do not. This can be configured through Area properties).

Which property? Is this true for Area2D as well? There is no mention of “event” on a whole Area2D page. How can I tell if my main (and only) Camera is attached to a viewport (I don’t see anything resembling viewport connection in root nor Camera)? Maybe something is stealing the event, but I have no idea how to debug that. I read in other question about setting mouse filter to ignore on root or parent container, that didn’t do anything.

Any tips would be appreciated.

Edit1: I also tried simpler case with root -> Node2D -> CanvasLayer -> ColorRect and no instancing from code. I still didn’t manage to get it working. I tried changing z-index, mouse filter property on all parents (where it’s available) and made sure Area2D is in one collision layer (some issues on GitHub suggested it’s required), but nothing helped.

:bust_in_silhouette: Reply From: monnef

I got it fixed by converting ColorRect into Node2D and recreated it inside this new node. I also had to set all containers and panels which were behind the Area2D to have mouse filter = ignore.

Setting ColorRect’s mouse filter to ignore didn’t work when it was a root of the scene (so when Area2D was its indirect child).