Godot Version
4.6.1
Question
i have no idea whats wrong, its been working fine a moment ago and now apparently its not, any idea what might be the problem?
class_name Menu extends Control
signal button_focused(button: BaseButton)
signal button_pressed(button: BaseButton)
var index: int = 0
func get_buttons() -> Array:
return get_children()
func _ready() -> void:
var _class: String = get_class()
for button in get_buttons():
button.focus_exited.connect(_on_Button_focus_exited.bind(button))
button.focus_entered.connect(_on_Button_focused.bind(button))
button.pressed.connect(_on_Button_pressed.bind(button)) #heres the problem
func connect_to_buttons(target: Object, _name: String = name) -> void:
var callable: Callable = Callable()
callable = Callable(target, "_on_" + _name + "_focused")
button_focused.connect(callable)
callable = Callable(target, "_on_" + _name + "_pressed")
button_pressed.connect(callable)
func button_focus(n: int = index) -> void:
var button: BaseButton = get_buttons()[n]
button.grab_focus()
func _on_Button_focus_exited(button: BaseButton) -> void:
await get_tree().process_frame
if not get_viewport().gui_get_focus_owner() in get_buttons():
button.grab_focus()
func _on_Button_focused(button: BaseButton) -> void:
emit_signal("button_focused", button)
func _on_Button_pressed(button: BaseButton) -> void:
emit_signal("button_pressed", button)
the problem is on line 17