ItemList: Get Selected Item ID

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By kaleidx
:warning: Old Version Published before Godot 3 was released.

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 … get_selected_ID, but not sure how to do that for an ItemList.

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

:bust_in_silhouette: Reply From: whooshfrosted

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))