0 votes

Seems very simple but I can't seem to find any info on the subject. How do I get a selected item's ID so I can manipulate it further?
OptionButton was very straightforward ... getselectedID, but not sure how to do that for an ItemList.

From the Documentation ...
getselecteditems ( ) gives an array, but not sure where to go from there.

in Engine by (28 points)

1 Answer

+2 votes

You can attach metadata to an item:

ItemList.get_item_metadata
ItemList.set_item_metadata


for ability in character.get_node("ability").get_children():
    if ability.satisfies_requirements():
        ability_list.add_item(ability.name, null, true)
        ability_list.set_item_metadata(ability_list.get_item_count() - 1, ability)

Then you can loop through the get_selected_items array:

for ....
gui.set_description(ability_list.get_item_metadata(idx))
by (243 points)
edited by
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.