#How do I add a search bar for an item list?
1 messages · Page 1 of 1 (latest)
Let's say you have a scene sort of like this:
LineEdit: This is your search boxVBoxContainer: This contains the list you want to search throughLabel: One for each item (you could have this be something other thanLabelas long as it has text in it somewhere)
As the user types into the LineEdit, it will emit the text_changedsignal. When that happens, go through each of the items in the list and show/hide them.
Something like this (I'm on my phone so I'm not actually testing it 😅)
func _on_text_changed(new_text: String):
for item in container:
item.visible = item.text.containsn(new_text)
Thank you! I am trying to use the itemlist node for the search items (it makes it easier to add images, texts and buttons), but I'll see if this works
Yeah I would create a scene with each item and then give it a function like get_text that would return whatever text is in the label
Just tried it, it works!