godotgodot4

How to have two Control nodes occupying the same space without only one being able to accept inputs


I have two Control nodes as children of another node sharing space on the screen, and within both I want to have ScrollContainers or similarly operating nodes the user can interact with. However, just changing the zindex does not do anything in that regard besides visually; the top one will always take the user input. I cannot just hide the other control node, though, because only some of the parts (like where the ScrollContainers are) actually overlap; it would be jarring if the user couldn't see one Control's children when utilizing the other. Is there a way to get around this, or do I just need to break up the Control nodes into multiple and try to synchronize them with signals?


Solution

  • Because two Control nodes physically overlapping each other will always follow the input level set down by their positions in the scene tree, only the node farthest down in the tree will ever receive inputs. In order to bypass this, you need to turn off the processes of the node that you aren't using, making it incapable of registering inputs (as per @JaB 's comment [thank you again]).

    Since I still want some children of each Control node to be capable of receiving input, I have to set those nodes' process_modes to Always, while leaving the rest as Inherit. This way, I can just change the process_mode of the parent Control node I don't want to be interactable to Disabled and Always when I do, and the inheriting nodes will fall in line.

    EDIT: The above does not work.

    I ended up having to use propogate_call("set_mouse_filter", [MOUSE_FILTER_IGNORE]) on the Control node I wanted to shut off then manually set the mouse filters of its child nodes I did want to be interactive to MOUSE_FILTER_STOP.