ItemList with more than one item?

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

I’ve been using ItemList, but it only takes one string of text and an optional icon. What I would like is to have two columns of text on the same line like in this image. See the Pick A Perk box with the text in green and yellow.

The name and numbers in () are the same selectable line, but they are in different columns that line up.

With the font I’m using if I put it all in the same line separated by spaces, the second column does not line up. Is there an alternative to ItemList that can have mutliple strings in the same item, or should I make a feature request?

you can do this with Tree with set_hide_root(true)

volzhs | 2017-04-04 15:19

:bust_in_silhouette: Reply From: jospic

In the script of the ItemList node you must insert:


where MAXCOL is a constant for number of columns for a row.


good to know :slight_smile:

volzhs | 2017-04-04 17:23

That doesn’t work for what I need. It just makes different entries appear in different columns.

If you look at the picture, I want to separate the text inside an entry. The numbers in brackets aren’t a separate entry, they are ranks for each entry.

whooshfrosted | 2017-04-05 00:35

What’s the problem? You may use two different columns, but selectable together…
In the past I’ve made a Godot database application (SQlite) that used itemlist control with seven fields for a row.

Example of multicolumn Godot ItemList

jospic | 2017-04-05 07:20

So how did you make them selectable together?

whooshfrosted | 2017-04-06 03:10

It’s simple. Put a signal “item_selected” on ItemList like this:

func _on_ItemList_item_selected( index ):
var i
index = int(index / MAXCOL) * MAXCOL 

# set background color for all fields in the row
for i in range (0, MAXCOL):
	self.set_item_custom_bg_color(index + i, Color (0, 0, 1))

jospic | 2017-04-06 08:19

Wow that’s cool. Thank you!

whooshfrosted | 2017-04-06 10:22

I know this is an old thread, but I just wanted to also thank you - almost gave up using the ItemList because of it’s lack of multi item columns. Your hack saved me a lot of time rolling my own solution.

LGallion | 2018-11-18 00:37