32 lines
747 B
GDScript
32 lines
747 B
GDScript
extends TabContainer
|
|
|
|
var pass_to_actor
|
|
|
|
func _ready() -> void:
|
|
for child in get_children():
|
|
if "leave_stage" in child:
|
|
child.leave_stage.connect(_on_stage_left)
|
|
tab_changed.connect(_on_tab_changed)
|
|
|
|
# Initialize the first tab's focus state
|
|
var initial_child = get_child(current_tab)
|
|
if "focused" in initial_child:
|
|
initial_child.focused = true
|
|
pass_to_actor = initial_child
|
|
|
|
func _on_tab_changed(tab_id: int):
|
|
# Transfer focused to the new tab's child
|
|
for child in get_children():
|
|
if "focused" in child:
|
|
child.focused = false
|
|
|
|
var new_child = get_child(tab_id)
|
|
if "focused" in new_child:
|
|
new_child.focused = true
|
|
|
|
pass_to_actor = new_child
|
|
|
|
func _on_stage_left():
|
|
await get_tree().process_frame
|
|
get_parent().vanish()
|