user24460252
user24460252

Reputation:

How to Use A Texture With ItemList In Godot 4?

I'm creating a quiz game in Godot 4.2 and wanted to use a texture with an itemlist, similar to texture buttons. All I've seen so far is how to use a picture as an Icon, not as a texture. I want each item in this ItemList to have normal and pressed texture scenes.

I've searched through the docs and found a post which set the texture through code item_list.add_item("my_options_text"), load("res://Resource/Button (1).png"), true), but for mine the only thing it did was use it as an icon. Any ideas on how to do it?

Upvotes: 2

Views: 211

Answers (1)

Ivy O'Neal-Odom
Ivy O'Neal-Odom

Reputation: 111

I'm a little confused by your question but I think I can answer both possible interpretations.

You can add a texture to your ItemList options by dragging and dropping them (or selecting them via the file explorer) here:

enter image description here

I think this should work for most applications. The selected option (or options, if you have Select Mode set to Multi) is highlighted:

enter image description here

If you want more customized behavior, you would probably be best served by creating a custom Theme for the ItemList or by modifying the Theme Overrides.

If that doesn't work, you could also simply create a TextureButton scene with all the functionality you want in your buttons and then create a GridContainer filled with instances of that scene.

Upvotes: 0

Related Questions