Settings for menu control

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Davidek383
:warning: Old Version Published before Godot 3 was released.

Hi, I am messing with menu in my game and cant figure out how to select buttons with pressing keys. I have a ButtonGroup and buttons in it. I found that buttons have in params Focus Neighbour so I set it up but it doesnt work… I expect that I have forgotten smt and its really noob problem so please help me out…

:bust_in_silhouette: Reply From: avencherus

If you’re looking to send focus to a control. Control objects have a method called .grab_focus()

Docs: Control — Godot Engine (stable) documentation in English

Assuming you have a Control node with a Button node named Button as it’s child:
With something like this, you can send focus by hitting any keyboard key.

extends Control

func _ready():
	set_process_input(true)
	
func _input(event):
	if(event.type == InputEvent.KEY):
		get_node("Button").grab_focus()
:bust_in_silhouette: Reply From: atze

To use the focus neighours you have to focus on it’s neighbours in a script.
Like

    func _ready():
        ButtonGroup.get_button_list()[0].grab_focus()