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.

Methods

void add_icon_item ( Texture icon, bool selectable=true )
void add_item ( String text, Texture icon=null, bool selectable=true )
void clear ( )
void ensure_current_is_visible ( )
int get_item_at_position ( Vector2 position, bool exact=false ) const
int get_item_count ( ) const
Color get_item_custom_bg_color ( int idx ) const
Color get_item_custom_fg_color ( int idx ) const
Texture get_item_icon ( int idx ) const
Color get_item_icon_modulate ( int idx ) const
Rect2 get_item_icon_region ( int idx ) const
Variant get_item_metadata ( int idx ) const
String get_item_text ( int idx ) const
String get_item_tooltip ( int idx ) const
PoolIntArray get_selected_items ( )
VScrollBar get_v_scroll ( )
bool is_anything_selected ( )
bool is_item_disabled ( 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, Texture icon )
void set_item_icon_modulate ( int idx, Color modulate )
void set_item_icon_region ( int idx, Rect2 rect )
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_tooltip ( int idx, String tooltip )
void set_item_tooltip_enabled ( int idx, bool enable )
void sort_items_by_text ( )
void unselect ( int idx )
void unselect_all ( )

Theme Properties

StyleBox bg
StyleBox bg_focus
StyleBox cursor
StyleBox cursor_unfocused
Font font
Color font_color
Color font_color_selected
Color guide_color
int hseparation
int icon_margin
int line_separation
StyleBox selected
StyleBox selected_focus
int vseparation

Signals

  • item_activated ( int index )

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

  • item_rmb_selected ( int index, Vector2 at_position )

Fired 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 )

Fired when specified item has been selected.

allow_reselect must be enabled to reselect an item.

  • multi_selected ( int index, bool selected )

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

  • nothing_selected ( )
  • rmb_clicked ( Vector2 at_position )

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
Setter set_allow_reselect(value)
Getter get_allow_reselect()

If true the currently selected item may be selected again.

  • bool allow_rmb_select
Setter set_allow_rmb_select(value)
Getter get_allow_rmb_select()

If true a right mouse button click can select items.

Setter set_auto_height(value)
Getter has_auto_height()
  • int fixed_column_width
Setter set_fixed_column_width(value)
Getter get_fixed_column_width()
Setter set_fixed_icon_size(value)
Getter get_fixed_icon_size()
Setter set_icon_mode(value)
Getter get_icon_mode()
Setter set_icon_scale(value)
Getter get_icon_scale()
  • int max_columns
Setter set_max_columns(value)
Getter get_max_columns()
  • int max_text_lines
Setter set_max_text_lines(value)
Getter get_max_text_lines()
  • bool same_column_width
Setter set_same_column_width(value)
Getter is_same_column_width()
Setter set_select_mode(value)
Getter get_select_mode()

Allow single or multiple 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 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

Return count of items currently in the item list.

  • Color get_item_custom_bg_color ( int idx ) const
  • Color get_item_custom_fg_color ( int idx ) const
  • 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

Return the text for specified item index.

Return tooltip hint for specified item index.

Returns the list of selected indexes.

Returns the current vertical scroll bar for 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_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 at index from_idx to to_idx.

  • void remove_item ( int idx )

Remove item at specified 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 )
  • void set_item_custom_fg_color ( int idx, Color custom_fg_color )
  • void set_item_disabled ( int idx, bool disabled )

Disable (or enable) item at specified index.

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

Set (or replace) icon of the item at the specified index.

  • void set_item_icon_modulate ( int idx, Color modulate )

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

  • void set_item_icon_region ( int idx, Rect2 rect )
  • void set_item_metadata ( int idx, Variant metadata )

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

  • void set_item_selectable ( int idx, bool selectable )

Allow or disallow selection of the item at the specified index.

  • void set_item_text ( int idx, String text )

Sets text of item at specified index.

  • void set_item_tooltip ( int idx, String tooltip )

Sets tooltip hint for item at specified index.

  • void set_item_tooltip_enabled ( int idx, bool enable )

Sets whether the tooltip is enabled for specified item index.

  • void sort_items_by_text ( )

Sorts items in the list by their text.

  • void unselect ( int idx )

Ensure item at specified index is not selected.

  • void unselect_all ( )

Ensure there are no items selected.