ItemList

Inherits: Control < CanvasItem < Node < Object

Category: Core

Brief Description

Control that provides a list of selectable items (and/or icons) in a single column, or optionally in multiple columns.

Properties

boolallow_reselect
boolallow_rmb_select
boolauto_height
intfixed_column_width
Vector2fixed_icon_size
IconModeicon_mode
floaticon_scale
intmax_columns
intmax_text_lines
boolsame_column_width
SelectModeselect_mode

Methods

voidadd_icon_item ( Texture icon, bool selectable=true )
voidadd_item ( String text, Texture icon=null, bool selectable=true )
voidclear ( )
voidensure_current_is_visible ( )
intget_item_at_position ( Vector2 position, bool exact=false ) const
intget_item_count ( ) const
Colorget_item_custom_bg_color ( int idx ) const
Colorget_item_custom_fg_color ( int idx ) const
Textureget_item_icon ( int idx ) const
Colorget_item_icon_modulate ( int idx ) const
Rect2get_item_icon_region ( int idx ) const
Variantget_item_metadata ( int idx ) const
Stringget_item_text ( int idx ) const
Stringget_item_tooltip ( int idx ) const
PoolIntArrayget_selected_items ( )
VScrollBarget_v_scroll ( )
boolis_anything_selected ( )
boolis_item_disabled ( int idx ) const
boolis_item_icon_transposed ( int idx ) const
boolis_item_selectable ( int idx ) const
boolis_item_tooltip_enabled ( int idx ) const
boolis_selected ( int idx ) const
voidmove_item ( int from_idx, int to_idx )
voidremove_item ( int idx )
voidselect ( int idx, bool single=true )
voidset_item_custom_bg_color ( int idx, Color custom_bg_color )
voidset_item_custom_fg_color ( int idx, Color custom_fg_color )
voidset_item_disabled ( int idx, bool disabled )
voidset_item_icon ( int idx, Texture icon )
voidset_item_icon_modulate ( int idx, Color modulate )
voidset_item_icon_region ( int idx, Rect2 rect )
voidset_item_icon_transposed ( int idx, bool rect )
voidset_item_metadata ( int idx, Variant metadata )
voidset_item_selectable ( int idx, bool selectable )
voidset_item_text ( int idx, String text )
voidset_item_tooltip ( int idx, String tooltip )
voidset_item_tooltip_enabled ( int idx, bool enable )
voidsort_items_by_text ( )
voidunselect ( int idx )
voidunselect_all ( )

Theme Properties

StyleBoxbg
StyleBoxbg_focus
StyleBoxcursor
StyleBoxcursor_unfocused
Fontfont
Colorfont_color
Colorfont_color_selected
Colorguide_color
inthseparation
inticon_margin
intline_separation
StyleBoxselected
StyleBoxselected_focus
intvseparation

Signals

  • item_activated ( int index )

Triggered when specified list item is activated via double click or Enter.


  • item_rmb_selected ( int index, Vector2 at_position )

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.


  • item_selected ( int index )

Triggered when specified item has been selected.

allow_reselect must be enabled to reselect an item.


  • multi_selected ( int index, bool selected )

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


  • nothing_selected ( )

Triggered when a left mouse click is issued within the rect of the list but on empty space.


  • rmb_clicked ( Vector2 at_position )

Triggered when a right mouse click is issued within the rect of the list but on empty space.

allow_rmb_select must be enabled.

Enumerations

enum IconMode:

  • ICON_MODE_TOP = 0
  • ICON_MODE_LEFT = 1

enum SelectMode:

  • SELECT_SINGLE = 0
  • SELECT_MULTI = 1

Description

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’ with a double click (or Enter key).

Property Descriptions

  • bool allow_reselect
Setterset_allow_reselect(value)
Getterget_allow_reselect()

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


  • bool allow_rmb_select
Setterset_allow_rmb_select(value)
Getterget_allow_rmb_select()

If true, right mouse button click can select items.


Setterset_auto_height(value)
Getterhas_auto_height()

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


  • int fixed_column_width
Setterset_fixed_column_width(value)
Getterget_fixed_column_width()

Sets the default column width in pixels.

If left to default value, each item will have a width equal to the width of its content and the columns will have an uneven width.


Setterset_fixed_icon_size(value)
Getterget_fixed_icon_size()

Sets the default icon size in pixels.


Setterset_icon_mode(value)
Getterget_icon_mode()

Sets the default position of the icon to either ICON_MODE_LEFT or ICON_MODE_TOP.


Setterset_icon_scale(value)
Getterget_icon_scale()

Sets the icon size to its initial size multiplied by the specified scale. Default value is 1.0.


  • int max_columns
Setterset_max_columns(value)
Getterget_max_columns()

Sets the maximum columns the list will have.

If set to anything other than the default, the content will be split among the specified columns.


  • int max_text_lines
Setterset_max_text_lines(value)
Getterget_max_text_lines()

  • bool same_column_width
Setterset_same_column_width(value)
Getteris_same_column_width()

If set to true, all columns will have the same width specified by fixed_column_width.


Setterset_select_mode(value)
Getterget_select_mode()

Allow single or multiple item selection. See the SELECT_* constants.

Method Descriptions

  • void add_icon_item ( Texture icon, bool selectable=true )

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 of null for a list item with no icon.

If selectable is true the list item will be selectable.


  • void clear ( )

Remove all items from the list.


  • void ensure_current_is_visible ( )

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


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

Given a position within the control return the item (if any) at that point.


  • int get_item_count ( ) const

Returns the number of items currently in the list.


  • Color get_item_custom_bg_color ( int idx ) const

Returns the Color set by set_item_custom_bg_color. Default value is Color(0, 0, 0, 0).


  • Color get_item_custom_fg_color ( int idx ) const

Returns the Color set by set_item_custom_fg_color. Default value is Color(0, 0, 0, 0).


Returns the icon associated with the specified index. Default value is null.


  • Color get_item_icon_modulate ( int idx ) const

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


  • Rect2 get_item_icon_region ( int idx ) const

Returns the metadata value of the specified index set by set_item_metadata.


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.


  • bool is_anything_selected ( )

Returns true if one or more items are selected.


  • bool is_item_disabled ( int idx ) const

Returns whether or not the item at the specified index is disabled.


  • bool is_item_icon_transposed ( int idx ) const

  • bool is_item_selectable ( int idx ) const

Returns whether or not the item at the specified index is selectable.


  • bool is_item_tooltip_enabled ( int idx ) const

Returns whether the tooltip is enabled for specified item index.


  • bool is_selected ( int idx ) const

Returns whether or not item at the specified index is currently selected.


  • void move_item ( int from_idx, int to_idx )

Moves item from index from_idx to to_idx.


  • void remove_item ( int idx )

Removes the item specified by idx index from the list.


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

Select the item at the specified index.

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


  • void set_item_custom_bg_color ( int idx, Color custom_bg_color )

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

  1. var some_string = "Some text"
  2. 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.

  • void set_item_custom_fg_color ( int idx, Color custom_fg_color )

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

  1. var some_string = "Some text"
  2. 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.

  • void set_item_disabled ( int idx, bool disabled )

Disable (or enable) item at the specified index.

Disabled items are not be selectable and do not trigger activation (Enter or double-click) signals.


Set (or replace) the icon’s Texture associated with the specified index.


  • void set_item_icon_modulate ( int idx, Color modulate )

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


  • void set_item_icon_region ( int idx, Rect2 rect )

  • void set_item_icon_transposed ( int idx, bool rect )

  • void set_item_metadata ( int idx, Variant metadata )

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


  • void set_item_selectable ( int idx, bool selectable )

Allow or disallow selection of the item associated with the specified index.


Sets text of the item associated with the specified index.


  • void set_item_tooltip ( int idx, String tooltip )

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


  • void set_item_tooltip_enabled ( int idx, bool enable )

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


  • void sort_items_by_text ( )

Sorts items in the list by their text.


  • void unselect ( int idx )

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


  • void unselect_all ( )

Ensure there are no items selected.