Godot Version
4.3
Question
Hi, I’m making a sort of “draft” type program where you can choose an option from multiple option buttons that are filled with names. A player can choose an option on one slot but should be disabled from another slot. I got that part like this:
func _on_item_selected(index: int) -> void:
#disables current selected index for all buttons
for node in get_tree().get_nodes_in_group("buttons"):
node.set_item_disabled(index,true)
And that works fine, but the player can change their mind and switch them to another slot.
So I added …
func _on_item_selected(index: int) -> void:
#disables current selected index for all buttons
for node in get_tree().get_nodes_in_group("buttons"):
node.set_item_disabled(index,true)
for item in node.get_item_count():
if node.get_item_index(item) != index:
node.set_item_disabled(item, false)
Say I have 3 buttons in a “buttons” group, with identical index lists. I select option 1 from button 1 so it disables option 1 from all other buttons so button 2 and 3 can not select it.
Then button 2 chooses item 2, but this code re-enables option 1 from button 1 for all buttons while disabling option 2 from button 1 and 3.
So I want to re-enable a choice that was CLICKED AWAY from from all other option buttons but NOT re-enable an item from a button with an item already selected.
I think I have to use get_selected()
somewhere but I’m not sure where and how.