Up to date

This page is up to date for Godot 4.2. If you still find outdated information, please open an issue.

ItemList

Inherits: Control < CanvasItem < Node < Object

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

Description

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.

Properties

bool

allow_reselect

false

bool

allow_rmb_select

false

bool

allow_search

true

bool

auto_height

false

bool

clip_contents

true (overrides Control)

int

fixed_column_width

0

Vector2i

fixed_icon_size

Vector2i(0, 0)

FocusMode

focus_mode

2 (overrides Control)

IconMode

icon_mode

1

float

icon_scale

1.0

int

item_count

0

int

max_columns

1

int

max_text_lines

1

bool

same_column_width

false

SelectMode

select_mode

0

OverrunBehavior

text_overrun_behavior

3

Methods

int

add_icon_item ( Texture2D icon, bool selectable=true )

int

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

void

clear ( )

void

deselect ( int idx )

void

deselect_all ( )

void

ensure_current_is_visible ( )

void

force_update_list_size ( )

int

get_item_at_position ( Vector2 position, bool exact=false ) const

Color

get_item_custom_bg_color ( int idx ) const

Color

get_item_custom_fg_color ( int idx ) const

Texture2D

get_item_icon ( int idx ) const

Color

get_item_icon_modulate ( int idx ) const

Rect2

get_item_icon_region ( int idx ) const

String

get_item_language ( int idx ) const

Variant

get_item_metadata ( int idx ) const

Rect2

get_item_rect ( int idx, bool expand=true ) const

String

get_item_text ( int idx ) const

TextDirection

get_item_text_direction ( int idx ) const

String

get_item_tooltip ( int idx ) const

PackedInt32Array

get_selected_items ( )

VScrollBar

get_v_scroll_bar ( )

bool

is_anything_selected ( )

bool

is_item_disabled ( int idx ) const

bool

is_item_icon_transposed ( int idx ) const

bool

is_item_selectable ( int idx ) const

bool

is_item_tooltip_enabled ( int idx ) const

bool

is_selected ( int idx ) const

void

move_item ( int from_idx, int to_idx )

void

remove_item ( int idx )

void

select ( int idx, bool single=true )

void

set_item_custom_bg_color ( int idx, Color custom_bg_color )

void

set_item_custom_fg_color ( int idx, Color custom_fg_color )

void

set_item_disabled ( int idx, bool disabled )

void

set_item_icon ( int idx, Texture2D icon )

void

set_item_icon_modulate ( int idx, Color modulate )

void

set_item_icon_region ( int idx, Rect2 rect )

void

set_item_icon_transposed ( int idx, bool transposed )

void

set_item_language ( int idx, String language )

void

set_item_metadata ( int idx, Variant metadata )

void

set_item_selectable ( int idx, bool selectable )

void

set_item_text ( int idx, String text )

void

set_item_text_direction ( int idx, TextDirection direction )

void

set_item_tooltip ( int idx, String tooltip )

void

set_item_tooltip_enabled ( int idx, bool enable )

void