immersive-home/app/content/ui/components/tabs/tabs.gd
2024-04-09 17:11:24 +02:00

32 lines
559 B
GDScript

extends Node3D
class_name Tabs3D
signal on_select(selected: int)
var selected = R.state(null)
@export var initial_selected: Node3D
func _ready():
if initial_selected:
selected.value = initial_selected
R.effect(func(_arg):
on_select.emit(selected.value)
)
for option in get_children():
if option is Button3D == false:
continue
option.on_button_down.connect(func():
selected.value=option
)
R.effect(func(_arg):
option.active=option == selected.value
option.disabled=option == selected.value
)
option.toggleable = true