Inherits: Control < CanvasItem < Node < Object
Control that provides a list of selectable items (and/or icons) in a single column, or optionally in multiple columns.
This control provides a selectable list of items that may be in a single (or multiple columns) with option of text, icons, or both text and 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 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.
bool | allow_reselect | false |
bool | allow_rmb_select | false |
bool | auto_height | false |
int | fixed_column_width | 0 |
Vector2 | fixed_icon_size | Vector2( 0, 0 ) |
FocusMode | focus_mode |
2 (parent override)
|
IconMode | icon_mode | 1 |
float | icon_scale | 1.0 |
int | max_columns | 1 |
int | max_text_lines | 1 |
bool | rect_clip_content |
true (parent override)
|
bool | same_column_width | false |
SelectMode | select_mode | 0 |
StyleBox | bg | |
StyleBox | bg_focus | |
StyleBox | cursor | |
StyleBox | cursor_unfocused | |
Font | font | |
Color | font_color | Color( 0.63, 0.63, 0.63, 1 ) |
Color | font_color_selected | Color( 1, 1, 1, 1 ) |
Color | guide_color | Color( 0, 0, 0, 0.1 ) |
int | hseparation | 4 |
int | icon_margin | 4 |
int | line_separation | 2 |
StyleBox | selected | |
StyleBox | selected_focus | |
int | vseparation | 2 |
Triggered when specified list item is activated via double-clicking or by pressing Enter.
Triggered when specified list item has been selected via right mouse clicking.
The click position is also provided to allow appropriate popup of context menus at the correct location.
allow_rmb_select must be enabled.
Triggered when specified item has been selected.
allow_reselect must be enabled to reselect an item.
Triggered when a multiple selection is altered on a list allowing multiple selection.
Triggered when a left mouse click is issued within the rect of the list but on empty space.
Triggered when a right mouse click is issued within the rect of the list but on empty space.
allow_rmb_select must be enabled.
enum IconMode:
enum SelectMode:
Default | false |
Setter | set_allow_reselect(value) |
Getter | get_allow_reselect() |
If true
, the currently selected item can be selected again.
Default | false |
Setter | set_allow_rmb_select(value) |
Getter | get_allow_rmb_select() |
If true
, right mouse button click can select items.
Default | false |
Setter | set_auto_height(value) |
Getter | has_auto_height() |
If true
, the control will automatically resize the height to fit its content.
Default | 0 |
Setter | set_fixed_column_width(value) |
Getter | get_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.
Default | Vector2( 0, 0 ) |
Setter | set_fixed_icon_size(value) |
Getter | get_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.
Default | 1 |
Setter | set_icon_mode(value) |
Getter | get_icon_mode() |
The icon position, whether above or to the left of the text. See the IconMode constants.
Default | 1.0 |
Setter | set_icon_scale(value) |
Getter | get_icon_scale() |
The scale of icon applied after fixed_icon_size and transposing takes effect.
Default | 1 |
Setter | set_max_columns(value) |
Getter | get_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.
Default | 1 |
Setter | set_max_text_lines(value) |
Getter | get_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 ICON_MODE_TOP. To make the text wrap, fixed_column_width should be greater than zero.
Default | false |
Setter | set_same_column_width(value) |
Getter | is_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.
Default | 0 |
Setter | set_select_mode(value) |
Getter | get_select_mode() |
Allows single or multiple item selection. See the SelectMode constants.
Adds an item to the item list with no text, only an icon.
Adds an item to the item list with specified text. 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.
Removes all items from the list.
Ensure current selection is visible, adjusting the scroll position as necessary.
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.
Returns the number of items currently in the list.
Returns the custom background color of the item specified by idx
index.
Returns the custom foreground color of the item specified by idx
index.
Returns the icon associated with the specified index.
Returns a Color modulating item's icon at the specified index.
Returns the region of item's icon used. The whole icon will be used if the region has no area.
Returns the metadata value of the specified index.
Returns the text associated with the specified index.
Returns the tooltip hint associated with the specified index.
Returns an array with the indexes of the selected items.
Returns the Object ID associated with the list.
Returns true
if one or more items are selected.
Returns true
if the item at the specified index is disabled.
Returns true
if the item icon will be drawn transposed, i.e. the X and Y axes are swapped.
Returns true
if the item at the specified index is selectable.
Returns true
if the tooltip is enabled for specified item index.
Returns true
if the item at the specified index is currently selected.
Moves item from index from_idx
to to_idx
.
Removes the item specified by idx
index from the list.
Select the item at the specified index.
Note: This method does not trigger the item selection signal.
Sets the background color of the item specified by idx
index to the specified Color.
var some_string = "Some text" some_string.set_item_custom_bg_color(0,Color(1, 0, 0, 1) # This will set the background color of the first item of the control to red.
Sets the foreground color of the item specified by idx
index to the specified Color.
var some_string = "Some text" some_string.set_item_custom_fg_color(0,Color(1, 0, 0, 1) # This will set the foreground color of the first item of the control to red.
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).
Sets (or replaces) the icon's Texture associated with the specified index.
Sets a modulating Color of the item associated with the specified index.
Sets the region of item's icon used. The whole icon will be used if the region has no area.
Sets whether the item icon will be drawn transposed.
Sets a value (of any type) to be stored with the item associated with the specified index.
Allows or disallows selection of the item associated with the specified index.
Sets text of the item associated with the specified index.
Sets the tooltip hint for the item associated with the specified index.
Sets whether the tooltip hint is enabled for specified item index.
Sorts items in the list by their text.
Ensures the item associated with the specified index is not selected.
Ensures there are no items selected.
© 2014–2020 Juan Linietsky, Ariel Manzur, Godot Engine contributors
Licensed under the MIT License.
https://docs.godotengine.org/en/3.2/classes/class_itemlist.html