0 votes

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..

in Engine by (18 points)

2 Answers

0 votes

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

Docs: http://docs.godotengine.org/en/stable/classes/class_control.html#class-control-grab-focus

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():

func _input(event):
    if(event.type == InputEvent.KEY):
by (5,264 points)
0 votes

To use the focus neighours you have to focus on it's neighbours in a script.
func _ready(): ButtonGroup.get_button_list()[0].grab_focus()

by (488 points)
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.