File tree Expand file tree Collapse file tree 1 file changed +8
-5
lines changed Expand file tree Collapse file tree 1 file changed +8
-5
lines changed Original file line number Diff line number Diff line change @@ -58,22 +58,25 @@ have well-defined vertical or horizontal navigation flow.
5858Necessary code
5959--------------
6060
61- For keyboard and controller navigation to work correctly, any node must be focused on
61+ For keyboard and controller navigation to work correctly, any node must be focused by
6262using code when the scene starts. Without doing this, pressing buttons or keys won't
63- do anything. Here is a basic example of setting initial focus with code:
63+ do anything.
64+
65+ You can use the :ref: `Control.grab_focus() <class_Control_method_grab_focus >` method
66+ to focus a control. Here is a basic example of setting initial focus with code:
6467
6568.. tabs ::
6669 .. code-tab :: gdscript GDScript
6770
6871 func _ready():
69- $StartButton.grab_focus()
72+ $StartButton.grab_focus.call_deferred ()
7073
7174 .. code-tab :: csharp
7275
7376 public override void _Ready()
7477 {
75- GetNode<Button>("StartButton").GrabFocus();
78+ GetNode<Button>("StartButton").GrabFocus.CallDeferred ();
7679 }
7780
78- Now when the scene starts the "Start Button" node will be focused, and the keyboard
81+ Now when the scene starts, the "Start Button" node will be focused, and the keyboard
7982or a controller can be used to navigate between it and other UI elements.
You can’t perform that action at this time.
0 commit comments