21 lines
386 B
GDScript
21 lines
386 B
GDScript
extends GridContainer
|
|
|
|
signal selected(idx)
|
|
|
|
func _ready():
|
|
var x := 0
|
|
for item in get_children():
|
|
item.toggled.connect(_on_button_toggled.bind(x))
|
|
x += 1
|
|
|
|
func select(index: int):
|
|
var x := 0
|
|
for item in get_children():
|
|
item.set_pressed_no_signal(x == index)
|
|
if item.button_pressed:
|
|
selected.emit(x)
|
|
x += 1
|
|
|
|
func _on_button_toggled(state: bool, idx: int):
|
|
select(idx)
|