ItemList Call Method On Item Select

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By deepseaprincess

Having difficulty figuring out how to get the ItemList to call a method in the attached script when an item is selected. Here’s what I have:

 extends ItemList

func _ready():
	var file ="db/cdb.json", file.READ)
	var text = file.get_as_text()
	var cdb = JSON.parse(text).result
	for key in cdb.keys():
func _on_ItemList_item_selected(index):

The ready code works fine and fills the ItemList as excpected. However, nothing prints when I click on an item in the list and the associated label does not change.
I’m kind of lost unfortunately.

Edit: Issue was that I wasn’t connecting the signal to the script, for anyone else having difficulty with this please review: Using signals — Godot Engine (stable) documentation in English

:bust_in_silhouette: Reply From: Inces

The code is good, must be an issue with input consuming.
Make sure there is no other control or canvas node on top of your menu, that is soaking input. If there is, set other control mouse filter settings to ignore, or manage input propagation in code.

Eventually You can check if your itemlist has proper item selection options - if mouse is allowed and which button.

Thanks for your response! I had the ItemList in a MarginContainer so I pulled it out of there but it still doesn’t seem to be working? This is what my scene looks like now:

enter image description here

I also tried removing the other MarginContainer so the only thing in the scene is the ItemList and that didn’t do anything? In addition: when I click on an item in the ItemList it highlights that item so it seems like the item is being selected but the method is just not being triggered?

deepseaprincess | 2021-10-11 15:45