Parent Control receiving gui_input when child Control has focus?

Godot Version

4.4

Question

I’m working on a settings screen and have a question about the best way to handle input.
My scene has a main SettingsScreen (a parent Control) which contains multiple child Control nodes (entries with value changers). When a child node like a slider has focus, the user can adjust its value. At the same time, I want the parent SettingsScreen to be able to react to global UI actions, like an “Apply Settings” command from a gamepad button press.

I tried overriding _gui_input(event) in the parent SettingsScreen script, assuming it was the correct method for UI-specific events. However, _gui_input() only seems to be called on the specific Control that currently has focus. The event does not propagate up to the parent when a child is focused.

What is the intended Godot pattern for handling this scenario? Should _unhandled_input() or _input() be used for handling UI input actions? If not, is there a way to make _gui_input() events propagate up the node tree to parents?

Use _unhandled_event() when you want to react to an input event that has not been consumed by _gui_input().

Use _input() if you need to react to an input event before it gets passed to _gui_input() or you need to stop its propagation.

More information about inputs events:

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.