Skip to content

ItemList

Inherits: Control < CanvasItem < Entity < Object

A vertical list of selectable items with one or multiple columns.

This control provides a vertical list of selectable items that may be in a single or in multiple columns, with each item having options for text and an icon. Tooltips are supported and may be different for every item in the list.

Selectable items in the list may be selected or deselected and multiple selection may be enabled. Selection with right mouse button may also be enabled to allow use of popup context menus. Items may also be “activated” by double-clicking them or by pressing Enter.

Item text only supports single-line strings. Newline characters (e.g. \n) in the string won’t produce a newline. Text wrapping is enabled in ICON_MODE_TOP mode, but the column’s width is adjusted to fully fit its content by default. You need to set fixed_column_width greater than zero to wrap the text.

All set_* methods allow negative item indices, i.e. -1 to access the last item, -2 to select the second-to-last item, and so on.

Incremental search: Like PopupMenu and Tree, ItemList supports searching within the list while the control is focused. Press a key that matches the first letter of an item’s name to select the first item starting with the given letter. After that point, there are two ways to perform incremental search: 1) Press the same key again before the timeout duration to select the next item starting with the same letter. 2) Press letter keys that match the rest of the word before the timeout duration to match to select the item in question directly. Both of these actions will be reset to the beginning of the list if the timeout duration has passed since the last keystroke was registered. You can adjust the timeout duration by changing ProjectSettings.gui/timers/incremental_search_max_interval_msec.

Type Name Default
bool allow_reselect false
bool allow_rmb_select false
bool allow_search true
bool auto_height false
bool auto_width false
bool clip_contents true (overrides Control)
int fixed_column_width 0
Vector2i fixed_icon_size Vector2i(0, 0)
Control.FocusMode focus_mode 2 (overrides Control)
IconMode icon_mode 1
float icon_scale 1.0
int item_count 0
bool item_{index}/disabled false
Texture2D item_{index}/icon
bool item_{index}/selectable true
String item_{index}/text ""
int max_columns 1
int max_text_lines 1
bool same_column_width false
ScrollHintMode scroll_hint_mode 0
SelectMode select_mode 0
TextSystem.OverrunBehavior text_overrun_behavior 3
bool tile_scroll_hint false
bool wraparound_items true
Returns Method
int add_icon_item(icon: Texture2D, selectable: bool = true)
int add_item(text: String, icon: Texture2D = null, selectable: bool = true)
void center_on_current(center_verically: bool = true, center_horizontally: bool = true)
void clear()
void deselect(idx: int)
void deselect_all()
void ensure_current_is_visible()
void force_update_list_size()
HScrollBar get_h_scroll_bar()
int get_item_at_position(position: Vector2, exact: bool = false) const
Entity.AutoTranslateMode get_item_auto_translate_mode(idx: int) const
Color get_item_custom_bg_color(idx: int) const
Color get_item_custom_fg_color(idx: int) const
Texture2D get_item_icon(idx: int) const
Color get_item_icon_modulate(idx: int) const
Rect2 get_item_icon_region(idx: int) const
String get_item_language(idx: int) const
Variant get_item_metadata(idx: int) const
Rect2 get_item_rect(idx: int, expand: bool = true) const
String get_item_text(idx: int) const
Control.TextDirection get_item_text_direction(idx: int) const
String get_item_tooltip(idx: int) const
PackedInt32Array get_selected_items()
VScrollBar get_v_scroll_bar()
bool is_anything_selected()
bool is_item_disabled(idx: int) const
bool is_item_icon_transposed(idx: int) const
bool is_item_selectable(idx: int) const
bool is_item_tooltip_enabled(idx: int) const
bool is_selected(idx: int) const
void move_item(from_idx: int, to_idx: int)
void remove_item(idx: int)
void select(idx: int, single: bool = true)
void set_item_auto_translate_mode(idx: int, mode: Entity.AutoTranslateMode)
void set_item_custom_bg_color(idx: int, custom_bg_color: Color)
void set_item_custom_fg_color(idx: int, custom_fg_color: Color)
void set_item_disabled(idx: int, disabled: bool)
void set_item_icon(idx: int, icon: Texture2D)
void set_item_icon_modulate(idx: int, modulate: Color)
void set_item_icon_region(idx: int, rect: Rect2)
void set_item_icon_transposed(idx: int, transposed: bool)
void set_item_language(idx: int, language: String)
void set_item_metadata(idx: int, metadata: Variant)
void set_item_selectable(idx: int, selectable: bool)
void set_item_text(idx: int, text: String)
void set_item_text_direction(idx: int, direction: Control.TextDirection)
void set_item_tooltip(idx: int, tooltip: String)
void set_item_tooltip_enabled(idx: int, enable: bool)
void sort_items_by_text()

empty_clicked

empty_clicked(at_position: Vector2, mouse_button_index: int)

Emitted when any mouse click is issued within the rect of the list but on empty space.

at_position is the click position in this control’s local coordinate system.

item_activated

item_activated(index: int)

Emitted when specified list item is activated via double-clicking or by pressing Enter.

item_clicked

item_clicked(index: int, at_position: Vector2, mouse_button_index: int)

Emitted when specified list item has been clicked with any mouse button.

at_position is the click position in this control’s local coordinate system.

item_selected

item_selected(index: int)

Emitted when specified item has been selected. Only applicable in single selection mode.

allow_reselect must be enabled to reselect an item.

multi_selected

multi_selected(index: int, selected: bool)

Emitted when a multiple selection is altered on a list allowing multiple selection.

IconMode

enum IconMode

ICON_MODE_TOP = 0

Icon is drawn above the text.

ICON_MODE_LEFT = 1

Icon is drawn to the left of the text.

SelectMode

enum SelectMode

SELECT_SINGLE = 0

Only allow selecting a single item.

SELECT_MULTI = 1

Allows selecting multiple items by holding Ctrl or Shift.

SELECT_TOGGLE = 2

Allows selecting multiple items by toggling them on and off.

ScrollHintMode

enum ScrollHintMode

SCROLL_HINT_MODE_DISABLED = 0

Scroll hints will never be shown.

SCROLL_HINT_MODE_BOTH = 1

Scroll hints will be shown at the top and bottom.

SCROLL_HINT_MODE_TOP = 2

Only the top scroll hint will be shown.

SCROLL_HINT_MODE_BOTTOM = 3

Only the bottom scroll hint will be shown.

font_color

Color font_color (color) = Color(0.65, 0.65, 0.65, 1)

font_disabled_color

Color font_disabled_color (color) = Color(0.875, 0.875, 0.875, 0.5)

font_disabled_hovered_color

Color font_disabled_hovered_color (color) = Color(0.875, 0.875, 0.875, 0.5)

font_hovered_color

Color font_hovered_color (color) = Color(0.95, 0.95, 0.95, 1)

font_hovered_selected_color

Color font_hovered_selected_color (color) = Color(1, 1, 1, 1)

font_outline_color

Color font_outline_color (color) = Color(0, 0, 0, 1)

font_selected_color

Color font_selected_color (color) = Color(1, 1, 1, 1)

guide_color

Color guide_color (color) = Color(0.7, 0.7, 0.7, 0.25)

scroll_hint_color

Color scroll_hint_color (color) = Color(0, 0, 0, 1)

h_separation

int h_separation (constant) = 4

icon_margin

int icon_margin (constant) = 4

line_separation

int line_separation (constant) = 2

outline_size

int outline_size (constant) = 0

scrollbar_h_separation

int scrollbar_h_separation (constant) = 4

scrollbar_margin_bottom

int scrollbar_margin_bottom (constant) = -1

scrollbar_margin_left

int scrollbar_margin_left (constant) = -1

scrollbar_margin_right

int scrollbar_margin_right (constant) = -1

scrollbar_margin_top

int scrollbar_margin_top (constant) = -1

v_separation

int v_separation (constant) = 4

font

Font font (font)

font_size

int font_size (font_size)

scroll_hint

Texture2D scroll_hint (icon)

focus_sound

AudioStream focus_sound (sound)

item_hovered_sound

AudioStream item_hovered_sound (sound)

item_selected_disabled_sound

AudioStream item_selected_disabled_sound (sound)

item_selected_sound

AudioStream item_selected_sound (sound)

cursor

StyleBox cursor (style)

cursor_unfocused

StyleBox cursor_unfocused (style)

disabled

StyleBox disabled (style)

disabled_hovered

StyleBox disabled_hovered (style)

focus

StyleBox focus (style)

hovered

StyleBox hovered (style)

hovered_selected

StyleBox hovered_selected (style)

hovered_selected_focus

StyleBox hovered_selected_focus (style)

panel

StyleBox panel (style)

selected

StyleBox selected (style)

selected_focus

StyleBox selected_focus (style)

allow_reselect

bool allow_reselect = false

If true, the currently selected item can be selected again.

allow_rmb_select

bool allow_rmb_select = false

If true, right mouse button click can select items.

bool allow_search = true

If true, allows navigating the ItemList with letter keys through incremental search.

auto_height

bool auto_height = false

If true, the control will automatically resize the height to fit its content.

auto_width

bool auto_width = false

If true, the control will automatically resize the width to fit its content.

fixed_column_width

int fixed_column_width = 0

The width all columns will be adjusted to.

A value of zero disables the adjustment, each item will have a width equal to the width of its content and the columns will have an uneven width.

fixed_icon_size

Vector2i fixed_icon_size = Vector2i(0, 0)

The size all icons will be adjusted to.

If either X or Y component is not greater than zero, icon size won’t be affected.

icon_mode

IconMode icon_mode = 1

The icon position, whether above or to the left of the text. See the IconMode constants.

icon_scale

float icon_scale = 1.0

The scale of icon applied after fixed_icon_size and transposing takes effect.

item_count

int item_count = 0

The number of items currently in the list.

item_{index}/disabled

bool item_{index}/disabled = false

If true, the item at index is disabled.

Note: index is a value in the 0 .. item_count - 1 range.

item_{index}/icon

Texture2D item_{index}/icon

The icon of the item at index.

Note: index is a value in the 0 .. item_count - 1 range.

item_{index}/selectable

bool item_{index}/selectable = true

If true, the item at index is selectable.

Note: index is a value in the 0 .. item_count - 1 range.

item_{index}/text

String item_{index}/text = ""

The text of the item at index.

Note: index is a value in the 0 .. item_count - 1 range.

max_columns

int max_columns = 1

Maximum columns the list will have.

If greater than zero, the content will be split among the specified columns.

A value of zero means unlimited columns, i.e. all items will be put in the same row.

max_text_lines

int max_text_lines = 1

Maximum lines of text allowed in each item. Space will be reserved even when there is not enough lines of text to display.

Note: This property takes effect only when icon_mode is ICON_MODE_TOP. To make the text wrap, fixed_column_width should be greater than zero.

same_column_width

bool same_column_width = false

Whether all columns will have the same width.

If true, the width is equal to the largest column width of all columns.

scroll_hint_mode

ScrollHintMode scroll_hint_mode = 0

The way which scroll hints (indicators that show that the content can still be scrolled in a certain direction) will be shown.

select_mode

SelectMode select_mode = 0

Allows single or multiple item selection. See the SelectMode constants.

text_overrun_behavior

TextSystem.OverrunBehavior text_overrun_behavior = 3

The clipping behavior when the text exceeds an item’s bounding rectangle.

tile_scroll_hint

bool tile_scroll_hint = false

If true, the scroll hint texture will be tiled instead of stretched. See scroll_hint_mode.

wraparound_items

bool wraparound_items = true

If true, the control will automatically move items into a new row to fit its content. See also HFlowContainer for this behavior.

If false, the control will add a horizontal scrollbar to make all items visible.

add_icon_item

int add_icon_item(icon: Texture2D, selectable: bool = true)

Adds an item to the item list with no text, only an icon. Returns the index of an added item.

add_item

int add_item(text: String, icon: Texture2D = null, selectable: bool = true)

Adds an item to the item list with specified text. Returns the index of an added item.

Specify an icon, or use null as the icon for a list item with no icon.

If selectable is true, the list item will be selectable.

center_on_current

void center_on_current(center_verically: bool = true, center_horizontally: bool = true)

Ensures the currently selected item (the first selected item if multiple selection is enabled) is visible, adjusting the scroll position as necessary to place the item at the center of the list if possible. See also ensure_current_is_visible().

Fails and prints an error if both arguments are false.

clear

void clear()

Removes all items from the list.

deselect

void deselect(idx: int)

Ensures the item associated with the specified index is not selected.

deselect_all

void deselect_all()

Ensures there are no items selected.

ensure_current_is_visible

void ensure_current_is_visible()

Ensures the currently selected item (the first selected item if multiple selection is enabled) is visible, adjusting the scroll position as necessary. See also center_on_current().

force_update_list_size

void force_update_list_size()

Forces an update to the list size based on its items. This happens automatically whenever size of the items, or other relevant settings like auto_height, change. The method can be used to trigger the update ahead of next drawing pass.

get_h_scroll_bar

HScrollBar get_h_scroll_bar()

Returns the horizontal scrollbar.

Warning: This is a required internal node, removing and freeing it may cause a crash. If you wish to hide it or any of its children, use their CanvasItem.visible property.

get_item_at_position

int get_item_at_position(position: Vector2, exact: bool = false) const

Returns the item index at the given position.

When there is no item at that point, -1 will be returned if exact is true, and the closest item index will be returned otherwise.

Note: The returned value is unreliable if called right after modifying the ItemList, before it redraws in the next frame.

get_item_auto_translate_mode

Entity.AutoTranslateMode get_item_auto_translate_mode(idx: int) const

Returns item’s auto translate mode.

get_item_custom_bg_color

Color get_item_custom_bg_color(idx: int) const

Returns the custom background color of the item specified by idx index.

get_item_custom_fg_color

Color get_item_custom_fg_color(idx: int) const

Returns the custom foreground color of the item specified by idx index.

get_item_icon

Texture2D get_item_icon(idx: int) const

Returns the icon associated with the specified index.

get_item_icon_modulate

Color get_item_icon_modulate(idx: int) const

Returns a Color modulating item’s icon at the specified index.

get_item_icon_region

Rect2 get_item_icon_region(idx: int) const

Returns the region of item’s icon used. The whole icon will be used if the region has no area.

get_item_language

String get_item_language(idx: int) const

Returns item’s text language code.

get_item_metadata

Variant get_item_metadata(idx: int) const

Returns the metadata value of the specified index.

get_item_rect

Rect2 get_item_rect(idx: int, expand: bool = true) const

Returns the position and size of the item with the specified index, in the coordinate system of the ItemList node. If expand is true the last column expands to fill the rest of the row.

Note: The returned value is unreliable if called right after modifying the ItemList, before it redraws in the next frame.

get_item_text

String get_item_text(idx: int) const

Returns the text associated with the specified index.

get_item_text_direction

Control.TextDirection get_item_text_direction(idx: int) const

Returns item’s text base writing direction.

get_item_tooltip

String get_item_tooltip(idx: int) const

Returns the tooltip hint associated with the specified index.

get_selected_items

PackedInt32Array get_selected_items()

Returns an array with the indexes of the selected items.

get_v_scroll_bar

VScrollBar get_v_scroll_bar()

Returns the vertical scrollbar.

Warning: This is a required internal node, removing and freeing it may cause a crash. If you wish to hide it or any of its children, use their CanvasItem.visible property.

is_anything_selected

bool is_anything_selected()

Returns true if one or more items are selected.

is_item_disabled

bool is_item_disabled(idx: int) const

Returns true if the item at the specified index is disabled.

is_item_icon_transposed

bool is_item_icon_transposed(idx: int) const

Returns true if the item icon will be drawn transposed, i.e. the X and Y axes are swapped.

is_item_selectable

bool is_item_selectable(idx: int) const

Returns true if the item at the specified index is selectable.

is_item_tooltip_enabled

bool is_item_tooltip_enabled(idx: int) const

Returns true if the tooltip is enabled for specified item index.

is_selected

bool is_selected(idx: int) const

Returns true if the item at the specified index is currently selected.

move_item

void move_item(from_idx: int, to_idx: int)

Moves item from index from_idx to to_idx.

remove_item

void remove_item(idx: int)

Removes the item specified by idx index from the list.

select

void select(idx: int, single: bool = true)

Selects the item at the specified index.

Note: This method does not trigger the item selection signal.

set_item_auto_translate_mode

void set_item_auto_translate_mode(idx: int, mode: Entity.AutoTranslateMode)

Sets the auto translate mode of the item associated with the specified index.

Items use Entity.AUTO_TRANSLATE_MODE_INHERIT by default, which uses the same auto translate mode as the ItemList itself.

set_item_custom_bg_color

void set_item_custom_bg_color(idx: int, custom_bg_color: Color)

Sets the background color of the item specified by idx index to the specified Color.

set_item_custom_fg_color

void set_item_custom_fg_color(idx: int, custom_fg_color: Color)

Sets the foreground color of the item specified by idx index to the specified Color.

set_item_disabled

void set_item_disabled(idx: int, disabled: bool)

Disables (or enables) the item at the specified index.

Disabled items cannot be selected and do not trigger activation signals (when double-clicking or pressing Enter).

set_item_icon

void set_item_icon(idx: int, icon: Texture2D)

Sets (or replaces) the icon’s Texture2D associated with the specified index.

set_item_icon_modulate

void set_item_icon_modulate(idx: int, modulate: Color)

Sets a modulating Color of the item associated with the specified index.

set_item_icon_region

void set_item_icon_region(idx: int, rect: Rect2)

Sets the region of item’s icon used. The whole icon will be used if the region has no area.

set_item_icon_transposed

void set_item_icon_transposed(idx: int, transposed: bool)

Sets whether the item icon will be drawn transposed.

set_item_language

void set_item_language(idx: int, language: String)

Sets the language code of the text for the item at the given index to language. This is used for line-breaking and text shaping algorithms. If language is empty, the current locale is used.

set_item_metadata

void set_item_metadata(idx: int, metadata: Variant)

Sets a value (of any type) to be stored with the item associated with the specified index.

set_item_selectable

void set_item_selectable(idx: int, selectable: bool)

Allows or disallows selection of the item associated with the specified index.

set_item_text

void set_item_text(idx: int, text: String)

Sets text of the item associated with the specified index.

set_item_text_direction

void set_item_text_direction(idx: int, direction: Control.TextDirection)

Sets item’s text base writing direction.

set_item_tooltip

void set_item_tooltip(idx: int, tooltip: String)

Sets the tooltip hint for the item associated with the specified index.

set_item_tooltip_enabled

void set_item_tooltip_enabled(idx: int, enable: bool)

Sets whether the tooltip hint is enabled for specified item index.

sort_items_by_text

void sort_items_by_text()

Sorts items in the list by their text.