Table of Contents

Class ItemList

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

Inheritance
ItemList

Remarks

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 ItemList.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 gui/timers/incremental_search_max_interval_msec.

Properties

allow_reselect

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

var allow_reselect : bool = false

Property Value

bool

Remarks

  • void set_allow_reselect(bool value)
  • bool get_allow_reselect

allow_rmb_select

If true, right mouse button click can select items.

var allow_rmb_select : bool = false

Property Value

bool

Remarks

  • void set_allow_rmb_select(bool value)
  • bool get_allow_rmb_select

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

var allow_search : bool = true

Property Value

bool

Remarks

  • void set_allow_search(bool value)
  • bool get_allow_search

auto_height

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

var auto_height : bool = false

Property Value

bool

Remarks

  • void set_auto_height(bool value)
  • bool has_auto_height

auto_width

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

var auto_width : bool = false

Property Value

bool

Remarks

  • void set_auto_width(bool value)
  • bool has_auto_width

fixed_column_width

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.

var fixed_column_width : int = 0

Property Value

int

Remarks

  • void set_fixed_column_width(int value)
  • int get_fixed_column_width

fixed_icon_size

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.

var fixed_icon_size : Vector2i = Vector2i(0, 0)

Property Value

Vector2i

Remarks

icon_mode

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

var icon_mode : int = 1

Property Value

int

Remarks

  • void set_icon_mode(int value)
  • int get_icon_mode

icon_scale

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

var icon_scale : float = 1.0

Property Value

float

Remarks

  • void set_icon_scale(float value)
  • float get_icon_scale

item_count

The number of items currently in the list.

var item_count : int = 0

Property Value

int

Remarks

  • void set_item_count(int value)
  • int get_item_count

max_columns

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.

var max_columns : int = 1

Property Value

int

Remarks

  • void set_max_columns(int value)
  • int get_max_columns

max_text_lines

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 ItemList.ICON_MODE_TOP. To make the text wrap, fixed_column_width should be greater than zero.

var max_text_lines : int = 1

Property Value

int

Remarks

  • void set_max_text_lines(int value)
  • int get_max_text_lines

same_column_width

Whether all columns will have the same width.

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

var same_column_width : bool = false

Property Value

bool

Remarks

  • void set_same_column_width(bool value)
  • bool is_same_column_width

select_mode

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

var select_mode : int = 0

Property Value

int

Remarks

  • void set_select_mode(int value)
  • int get_select_mode

text_overrun_behavior

Sets the clipping behavior when the text exceeds an item's bounding rectangle. See OverrunBehavior for a description of all modes.

var text_overrun_behavior : int = 3

Property Value

int

Remarks

  • void set_text_overrun_behavior(int value)
  • int get_text_overrun_behavior

wraparound_items

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.

var wraparound_items : bool = true

Property Value

bool

Remarks

  • void set_wraparound_items(bool value)
  • bool has_wraparound_items

font_color

Theme Property

Default text Color of the item.

 = ``Color(0.65, 0.65, 0.65, 1)``

Property Value

Color

font_hovered_color

Theme Property

Text Color used when the item is hovered and not selected yet.

 = ``Color(0.95, 0.95, 0.95, 1)``

Property Value

Color

font_hovered_selected_color

Theme Property

Text Color used when the item is hovered and selected.

 = ``Color(1, 1, 1, 1)``

Property Value

Color

font_outline_color

Theme Property

The tint of text outline of the item.

 = ``Color(0, 0, 0, 1)``

Property Value

Color

font_selected_color

Theme Property

Text Color used when the item is selected, but not hovered.

 = ``Color(1, 1, 1, 1)``

Property Value

Color

guide_color

Theme Property

Color of the guideline. The guideline is a line drawn between each row of items.

 = ``Color(0.7, 0.7, 0.7, 0.25)``

Property Value

Color

h_separation

Theme Property

The horizontal spacing between items.

 = ``4``

Property Value

int

icon_margin

Theme Property

The spacing between item's icon and text.

 = ``4``

Property Value

int

line_separation

Theme Property

The vertical spacing between each line of text.

 = ``2``

Property Value

int

outline_size

Theme Property

The size of the item text outline.

Note: If using a font with multichannel_signed_distance_field enabled, its msdf_pixel_range must be set to at least twice the value of outline_size for outline rendering to look correct. Otherwise, the outline may appear to be cut off earlier than intended.

 = ``0``

Property Value

int

v_separation

Theme Property

The vertical spacing between items.

 = ``4``

Property Value

int

font

Theme Property

Font of the item's text.

Font font

Property Value

Font

font_size

Theme Property

Font size of the item's text.

int font_size

Property Value

int

cursor

Theme Property

StyleBox used for the cursor, when the ItemList is being focused.

StyleBox cursor

Property Value

StyleBox

cursor_unfocused

Theme Property

StyleBox used for the cursor, when the ItemList is not being focused.

StyleBox cursor_unfocused

Property Value

StyleBox

focus

Theme Property

The focused style for the ItemList, drawn on top of the background, but below everything else.

StyleBox focus

Property Value

StyleBox

hovered

Theme Property

StyleBox for the hovered, but not selected items.

StyleBox hovered

Property Value

StyleBox

hovered_selected

Theme Property

StyleBox for the hovered and selected items, used when the ItemList is not being focused.

StyleBox hovered_selected

Property Value

StyleBox

hovered_selected_focus

Theme Property

StyleBox for the hovered and selected items, used when the ItemList is being focused.

StyleBox hovered_selected_focus

Property Value

StyleBox

panel

Theme Property

The background style for the ItemList.

StyleBox panel

Property Value

StyleBox

selected

Theme Property

StyleBox for the selected items, used when the ItemList is not being focused.

StyleBox selected

Property Value

StyleBox

selected_focus

Theme Property

StyleBox for the selected items, used when the ItemList is being focused.

StyleBox selected_focus

Property Value

StyleBox

Methods

add_icon_item(Texture2D, bool)

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

int add_icon_item(Texture2D icon, bool selectable)

Parameters

icon Texture2D
selectable bool

add_item(String, Texture2D, bool)

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.

int add_item(String text, Texture2D icon, bool selectable)

Parameters

text String
icon Texture2D
selectable bool

clear

Removes all items from the list.

void clear

deselect(int)

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

void deselect(int idx)

Parameters

idx int

deselect_all

Ensures there are no items selected.

void deselect_all

ensure_current_is_visible

Ensure current selection is visible, adjusting the scroll position as necessary.

void ensure_current_is_visible

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.

void force_update_list_size

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 visible property.

HScrollBar get_h_scroll_bar

get_item_at_position(Vector2, bool)

Qualifiers: 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.

int get_item_at_position(Vector2 position, bool exact)

Parameters

position Vector2
exact bool

get_item_auto_translate_mode(int)

Qualifiers: const

Returns item's auto translate mode.

int get_item_auto_translate_mode(int idx)

Parameters

idx int

get_item_custom_bg_color(int)

Qualifiers: const

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

Color get_item_custom_bg_color(int idx)

Parameters

idx int

get_item_custom_fg_color(int)

Qualifiers: const

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

Color get_item_custom_fg_color(int idx)

Parameters

idx int

get_item_icon(int)

Qualifiers: const

Returns the icon associated with the specified index.

Texture2D get_item_icon(int idx)

Parameters

idx int

get_item_icon_modulate(int)

Qualifiers: const

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

Color get_item_icon_modulate(int idx)

Parameters

idx int

get_item_icon_region(int)

Qualifiers: const

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

Rect2 get_item_icon_region(int idx)

Parameters

idx int

get_item_language(int)

Qualifiers: const

Returns item's text language code.

String get_item_language(int idx)

Parameters

idx int

get_item_metadata(int)

Qualifiers: const

Returns the metadata value of the specified index.

Variant get_item_metadata(int idx)

Parameters

idx int

get_item_rect(int, bool)

Qualifiers: 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.

Rect2 get_item_rect(int idx, bool expand)

Parameters

idx int
expand bool

get_item_text(int)

Qualifiers: const

Returns the text associated with the specified index.

String get_item_text(int idx)

Parameters

idx int

get_item_text_direction(int)

Qualifiers: const

Returns item's text base writing direction.

int get_item_text_direction(int idx)

Parameters

idx int

get_item_tooltip(int)

Qualifiers: const

Returns the tooltip hint associated with the specified index.

String get_item_tooltip(int idx)

Parameters

idx int

get_selected_items

Returns an array with the indexes of the selected items.

PackedInt32Array get_selected_items

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 visible property.

VScrollBar get_v_scroll_bar

is_anything_selected

Returns true if one or more items are selected.

bool is_anything_selected

is_item_disabled(int)

Qualifiers: const

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

bool is_item_disabled(int idx)

Parameters

idx int

is_item_icon_transposed(int)

Qualifiers: const

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

bool is_item_icon_transposed(int idx)

Parameters

idx int

is_item_selectable(int)

Qualifiers: const

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

bool is_item_selectable(int idx)

Parameters

idx int

is_item_tooltip_enabled(int)

Qualifiers: const

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

bool is_item_tooltip_enabled(int idx)

Parameters

idx int

is_selected(int)

Qualifiers: const

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

bool is_selected(int idx)

Parameters

idx int

move_item(int, int)

Moves item from index from_idx to to_idx.

void move_item(int from_idx, int to_idx)

Parameters

from_idx int
to_idx int

remove_item(int)

Removes the item specified by idx index from the list.

void remove_item(int idx)

Parameters

idx int

select(int, bool)

Select the item at the specified index.

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

void select(int idx, bool single)

Parameters

idx int
single bool

set_item_auto_translate_mode(int, int)

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

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

void set_item_auto_translate_mode(int idx, int mode)

Parameters

idx int
mode int

set_item_custom_bg_color(int, Color)

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

void set_item_custom_bg_color(int idx, Color custom_bg_color)

Parameters

idx int
custom_bg_color Color

set_item_custom_fg_color(int, Color)

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

void set_item_custom_fg_color(int idx, Color custom_fg_color)

Parameters

idx int
custom_fg_color Color

set_item_disabled(int, 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).

void set_item_disabled(int idx, bool disabled)

Parameters

idx int
disabled bool

set_item_icon(int, Texture2D)

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

void set_item_icon(int idx, Texture2D icon)

Parameters

idx int
icon Texture2D

set_item_icon_modulate(int, Color)

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

void set_item_icon_modulate(int idx, Color modulate)

Parameters

idx int
modulate Color

set_item_icon_region(int, Rect2)

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

void set_item_icon_region(int idx, Rect2 rect)

Parameters

idx int
rect Rect2

set_item_icon_transposed(int, bool)

Sets whether the item icon will be drawn transposed.

void set_item_icon_transposed(int idx, bool transposed)

Parameters

idx int
transposed bool

set_item_language(int, String)

Sets language code of item's text used for line-breaking and text shaping algorithms, if left empty current locale is used instead.

void set_item_language(int idx, String language)

Parameters

idx int
language String

set_item_metadata(int, Variant)

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

void set_item_metadata(int idx, Variant metadata)

Parameters

idx int
metadata Variant

set_item_selectable(int, bool)

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

void set_item_selectable(int idx, bool selectable)

Parameters

idx int
selectable bool

set_item_text(int, String)

Sets text of the item associated with the specified index.

void set_item_text(int idx, String text)

Parameters

idx int
text String

set_item_text_direction(int, int)

Sets item's text base writing direction.

void set_item_text_direction(int idx, int direction)

Parameters

idx int
direction int

set_item_tooltip(int, String)

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

void set_item_tooltip(int idx, String tooltip)

Parameters

idx int
tooltip String

set_item_tooltip_enabled(int, bool)

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

void set_item_tooltip_enabled(int idx, bool enable)

Parameters

idx int
enable bool

sort_items_by_text

Sorts items in the list by their text.

void sort_items_by_text

Events

empty_clicked(Vector2, 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.

signal empty_clicked(Vector2 at_position, int mouse_button_index)

Parameters

at_position Vector2
mouse_button_index int

item_activated(int)

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

signal item_activated(int index)

Parameters

index int

item_clicked(int, Vector2, 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.

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

Parameters

index int
at_position Vector2
mouse_button_index int

item_selected(int)

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

allow_reselect must be enabled to reselect an item.

signal item_selected(int index)

Parameters

index int

multi_selected(int, bool)

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

signal multi_selected(int index, bool selected)

Parameters

index int
selected bool