Joystick-gamepads and menu buttons.

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

I am trying to find a way to make my in game menus compatible with a joystick.
The menu is extremely simple, just a node with Button children.
Looking at the Inspector tab of the Buttons I can see the Focus Neighbor but I cannot understand how to use them or how to make a button focused.

Sorry about this, but I just found out how to do it.
To set a button focused you can use the method .grab_focus()
Afterwards everything works as expected.

kakoeimon | 2016-06-24 11:25

Please, convert your comment into an answer, so that this won’t show up in the unanswered list. (probably select it as a best answer as well.)

Bojidar Marinov | 2016-06-27 09:41

:bust_in_silhouette: Reply From: kakoeimon

Godot have from default input map some joystick input. For example ui_accept to Return, Enter, Space and Device 0, Button 0. ui_left , ui_right and etc.
Those actions are automatically used for ui (user interface).
So if you grab focus for a button with the method .grab_focus you can point the button which is going to be highlighted in your menu. Afterwards int the inspector tab of the Button you can assign other buttons as neighbors. Up, down, left and right neighbors. Those are the buttons which are going to grab focus when you use the default ui input map.
Also if you use containers, those containers are going to take care of those neighbors. For example you do not have to manually set up the neighbors in a grid_container.