How to detect the same InputEvent in two overlapping Control Nodes

Godot Version



I am trying to make draggable elements that can interact with each other when dragged overtop each other. In the example below, I would like the garbage to be deleted when dropped onto the trash can.

Both elements connect to the gui_input signal. The idea is the garbage uses this signal to know when and where to be dragged by the mouse, and the trash can uses this signal to detect if it should delete something when the mouse button is released over it. The problem is that the trash can never calls its gui_input function while the garbage is being dragged. I imagine it is because of a condition preventing it from triggering.

The event won’t trigger if the control is obstructed by another Control on top of it, which doesn’t have mouse_filter set to MOUSE_FILTER_IGNORE;

However, I cannot set the garbage node to MOUSE_FILTER_IGNORE. It needs to detect mouse input for dragging to work.

An alternative solution is to leverage Godot’s drag functions, _get_drag_data(), set_drag_preview(), _can_drop_data(), and _drop_data(). My main issue with this option is that I want my dragged elements to be persistent, not ephemeral. set_drag_preview() automatically deletes the dragged element once the mouse button is released, which is behavior I don’t want.

What is a good solution to this problem?