ItemList

    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. ) in the string won’t produce a newline. Text wrapping is enabled in 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.

    Incremental search: Like 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 .

    Properties

    Methods

    void

    add_icon_item ( icon, bool selectable=true )

    void

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

    void

    ( )

    void

    ensure_current_is_visible ( )

    get_item_at_position ( position, bool exact=false ) const

    get_item_count ( ) const

    get_item_custom_bg_color ( idx ) const

    Color

    ( int idx ) const

    get_item_icon ( idx ) const

    Color

    ( int idx ) const

    get_item_icon_region ( idx ) const

    Variant

    ( int idx ) const

    get_item_text ( idx ) const

    String

    ( int idx ) const

    get_selected_items ( )

    get_v_scroll ( )

    is_anything_selected ( )

    is_item_disabled ( idx ) const

    bool

    ( int idx ) const

    is_item_selectable ( idx ) const

    bool

    ( int idx ) const

    is_selected ( idx ) const

    void

    move_item ( from_idx, int to_idx )

    void

    ( int idx )

    void

    ( int idx, single=true )

    void

    set_item_custom_bg_color ( idx, Color custom_bg_color )

    void

    ( int idx, custom_fg_color )

    void

    set_item_disabled ( idx, bool disabled )

    void

    ( int idx, icon )

    void

    set_item_icon_modulate ( idx, Color modulate )

    void

    ( int idx, rect )

    void

    set_item_icon_transposed ( idx, bool transposed )

    void

    void

    ( int idx, selectable )

    void

    set_item_text ( idx, String text )

    void

    ( int idx, tooltip )

    void

    set_item_tooltip_enabled ( idx, bool enable )

    void

    ( )

    void

    unselect ( idx )

    void

    unselect_all ( )

    Color

    Color( 0.63, 0.63, 0.63, 1 )

    Color

    Color( 1, 1, 1, 1 )

    Color

    Color( 0, 0, 0, 0.1 )

    int

    4

    int

    4

    int

    2

    int

    2

    Font

    StyleBox

    StyleBox

    StyleBox

    StyleBox

    StyleBox

    StyleBox

    Signals

    • item_activated ( index )

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


    • item_rmb_selected ( int index, 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 ( index )

    Triggered when specified item has been selected.

    allow_reselect must be enabled to reselect an item.


    • multi_selected ( 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 ( 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 is drawn above the text.

    • ICON_MODE_LEFT = 1 —- Icon is drawn to the left of the text.


    enum SelectMode:

    • SELECT_SINGLE = 0 —- Only allow selecting a single item.

    • SELECT_MULTI = 1 —- Allows selecting multiple items by holding Ctrl or Shift.

    • allow_reselect

    Default

    false

    Setter

    set_allow_reselect(value)

    Getter

    get_allow_reselect()

    If , the currently selected item can be selected again.


    • bool allow_rmb_select

    Default

    false

    Setter

    set_allow_rmb_select(value)

    Getter

    get_allow_rmb_select()

    If true, right mouse button click can select items.


    • auto_height

    Default

    false

    Setter

    set_auto_height(value)

    Getter

    has_auto_height()

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


    • int fixed_column_width

    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.


    • 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 constants.


    1.0

    Setter

    set_icon_scale(value)

    Getter

    get_icon_scale()

    The scale of icon applied after and transposing takes effect.


    • int max_columns

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


    • bool same_column_width

    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.


    • select_mode

    Default

    0

    Setter

    set_select_mode(value)

    Getter

    get_select_mode()

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

    Method Descriptions

    • void add_icon_item ( Texture icon, selectable=true )

    Adds an item to the item list with no text, only an icon.


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

    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.


    • void clear ( )

    Removes all items from the list.


    • void ensure_current_is_visible ( )

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


    • get_item_at_position ( Vector2 position, exact=false ) 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.


    • int get_item_count ( ) const

    Returns the number of items currently in the list.


    • get_item_custom_bg_color ( int idx ) const

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


    • get_item_custom_fg_color ( int idx ) const

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


    • get_item_icon ( int idx ) const

    Returns the icon associated with the specified index.


    • get_item_icon_modulate ( int idx ) const

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


    • Rect2 get_item_icon_region ( idx ) const

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


    • Variant get_item_metadata ( idx ) const

    Returns the metadata value of the specified index.


    • String get_item_text ( idx ) const

    Returns the text associated with the specified index.


    • String get_item_tooltip ( idx ) const

    Returns the tooltip hint associated with the specified index.


    Returns an array with the indexes of the selected items.


    • get_v_scroll ( )

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


    • is_anything_selected ( )

    Returns if one or more items are selected.


    • bool is_item_disabled ( idx ) const

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


    • bool is_item_icon_transposed ( idx ) const

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


    • bool is_item_selectable ( idx ) const

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


    • bool is_item_tooltip_enabled ( idx ) const

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


    • bool is_selected ( idx ) const

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


    • void move_item ( int from_idx, 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 ( idx, bool single=true )

    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 .


    • void set_item_custom_fg_color ( int idx, custom_fg_color )

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


    • void set_item_disabled ( idx, bool disabled )

    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_icon ( idx, Texture icon )

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


    • void set_item_icon_modulate ( int idx, modulate )

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


    • void set_item_icon_region ( idx, Rect2 rect )

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


    • void set_item_icon_transposed ( idx, bool transposed )

    Sets whether the item icon will be drawn transposed.


    • void set_item_metadata ( idx, Variant metadata )

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


    • void set_item_selectable ( idx, bool selectable )

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


    • void set_item_text ( idx, String text )

    Sets text of the item associated with the specified index.


    • void set_item_tooltip ( idx, String tooltip )

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


    • void set_item_tooltip_enabled ( 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 ( idx )

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


    • void unselect_all ( )

    Ensures there are no items selected.

    Theme Property Descriptions

    • font_color

    Default text Color of the item.


    • font_color_selected

    Default

    Color( 1, 1, 1, 1 )

    Text Color used when the item is selected.


    • guide_color

    Default

    Color( 0, 0, 0, 0.1 )

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


    • hseparation

    Default

    4

    The horizontal spacing between items.


    • int icon_margin

    Default

    4

    The spacing between item’s icon and text.


    • line_separation

    Default

    2

    The vertical spacing between each line of text.


    • int vseparation

    Default

    2

    The vertical spacing between items.


    • font

    Font of the item’s text.


    • bg

    Default StyleBox for the ItemList, i.e. used when the control is not being focused.


    • bg_focus

    StyleBox used when the ItemList is being focused.


    • cursor

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


    • cursor_unfocused

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


    • selected

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