From a8ccd619365dc5504bbb39a90fd4a9adaea46429 Mon Sep 17 00:00:00 2001 From: ProgrammerOnCoffee <171874668+ProgrammerOnCoffee@users.noreply.github.com> Date: Fri, 9 May 2025 14:53:30 -0400 Subject: [PATCH] Add `call_deferred` to UI Navigation code example --- tutorials/ui/gui_navigation.rst | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/tutorials/ui/gui_navigation.rst b/tutorials/ui/gui_navigation.rst index dbac7f486..d78082323 100644 --- a/tutorials/ui/gui_navigation.rst +++ b/tutorials/ui/gui_navigation.rst @@ -58,22 +58,25 @@ have well-defined vertical or horizontal navigation flow. Necessary code -------------- -For keyboard and controller navigation to work correctly, any node must be focused on +For keyboard and controller navigation to work correctly, any node must be focused by using code when the scene starts. Without doing this, pressing buttons or keys won't -do anything. Here is a basic example of setting initial focus with code: +do anything. + +You can use the :ref:`Control.grab_focus() ` method +to focus a control. Here is a basic example of setting initial focus with code: .. tabs:: .. code-tab:: gdscript GDScript func _ready(): - $StartButton.grab_focus() + $StartButton.grab_focus.call_deferred() .. code-tab:: csharp public override void _Ready() { - GetNode