Godot Version
4.1.1
Question
I’m trying to create menu with a pointer next to the menu options, highlighting the one in focus. While using ready function all the buttons return their global position as (0,0) and the pointer appears in the corner of the window instead. When i press a key to then choose the next option the buttons return their predicted global position, the problem only occurs in the initial setup.
extends Node2D
func _ready():
get_viewport().connect("gui_focus_changed", set_cursor)
$Control/VBoxContainer/HBoxContainer/VBoxContainer/LoadButton.grab_focus()
func set_cursor(focus_owner):
$Control/Pointer.position.y = focus_owner.global_position.y