Godot Version
4.3
Question
According to the tutorial, I made the game settings using TabContainer and TabBar, I want to make the game for both gamepad and keyboard and mouse, but using the grab_focus() command for TabBar in the script when going to the settings, I can't grab the focus. The command works with regular buttons, and if I select TabBar with the mouse, I can switch between them with the gamepad (I configured the focus in this regard). I hope for help
Code :
extends Node2D
func _ready() -> void:
var tween1 = get_tree().create_tween()
tween1.tween_property($MainMenu/CanvasLayer/ColorRect, "modulate:a", 0, 1)
$MainMenu/MarginContainer/VBoxContainer/Play.grab_focus()
func _process(delta: float) -> void:
pass
func _on_play_pressed() -> void:
get_tree().change_scene_to_file("res://Scenes/test_level.tscn")
func _on_options_pressed() -> void:
var tween1 = get_tree().create_tween()
tween1.tween_property($Camera, "position:x", 1728, 1).set_trans(Tween.TRANS_SINE)
`$Settings/TabContainer/Graphics.grab_focus()` <-(here is grab_focus for TabBar)
$Settings/TabContainer/Exit.disabled = false
func _on_quit_pressed() -> void:
get_tree().quit()
func _on_nelis_toggled(toggled_on: bool) -> void:
GlobalVars.nelis_pause_menu = false
func _on_back_button_pressed() -> void:
$MainMenu/MarginContainer/VBoxContainer/Play.grab_focus()
$Settings/TabContainer/Exit.disabled = true
var tween1 = get_tree().create_tween().set_trans(Tween.TRANS_SINE)
tween1.tween_property($Camera, "position:x", 576, 1)
Code with screenshot: