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

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.

Inheritance Chain

Constructors

    public ItemList()

Signals

    "item_activated" (int index)

Triggered when specified list item is activated via double-clicking or by pressing 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.

AllowRmbSelect must be enabled.

    "item_selected" (int index)

Triggered when specified item has been selected.

AllowReselect 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.

AllowRmbSelect must be enabled.

Properties

    public bool AllowReselect { get; set; }

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

    public bool AllowRmbSelect { get; set; }

If true, right mouse button click can select items.

    public bool AutoHeight { get; set; }

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

    public int FixedColumnWidth { get; set; }

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.

    public Vector2 FixedIconSize { get; set; }

Sets the default icon size in pixels.

    public IconModeEnum IconMode { get; set; }

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

    public float IconScale { get; set; }

Sets the icon size to its initial size multiplied by the specified scale.

    public Collections.Array Items { get; set; }

    public int MaxColumns { get; set; }

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.

    public int MaxTextLines { get; set; }

    public bool SameColumnWidth { get; set; }

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

    public SelectModeEnum SelectMode { get; set; }

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

Methods

    public void AddIconItem(Texture icon, bool selectable = true)

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

    public void AddItem(string text, Texture 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.

    public void Clear()

Removes all items from the list.

    public void EnsureCurrentIsVisible()

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

    [Obsolete("GetAllowReselect is deprecated. Use the AllowReselect property instead.")]
    public bool GetAllowReselect()

Getter for AllowReselect

    [Obsolete("GetAllowRmbSelect is deprecated. Use the AllowRmbSelect property instead.")]
    public bool GetAllowRmbSelect()

Getter for AllowRmbSelect

    [Obsolete("GetFixedColumnWidth is deprecated. Use the FixedColumnWidth property instead.")]
    public int GetFixedColumnWidth()

Getter for FixedColumnWidth

    [Obsolete("GetFixedIconSize is deprecated. Use the FixedIconSize property instead.")]
    public Vector2 GetFixedIconSize()

Getter for FixedIconSize

    [Obsolete("GetIconMode is deprecated. Use the IconMode property instead.")]
    public IconModeEnum GetIconMode()

Getter for IconMode

    [Obsolete("GetIconScale is deprecated. Use the IconScale property instead.")]
    public float GetIconScale()

Getter for IconScale

    public int GetItemAtPosition(Vector2 position, bool exact = false)

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

    public int GetItemCount()

Returns the number of items currently in the list.

    public Color GetItemCustomBgColor(int idx)

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

    public Color GetItemCustomFgColor(int idx)

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

    public Texture GetItemIcon(int idx)

Returns the icon associated with the specified index.

    public Color GetItemIconModulate(int idx)

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

    public Rect2 GetItemIconRegion(int idx)

    public object GetItemMetadata(int idx)

Returns the metadata value of the specified index.

    public string GetItemText(int idx)

Returns the text associated with the specified index.

    public string GetItemTooltip(int idx)

Returns the tooltip hint associated with the specified index.

    [Obsolete("GetMaxColumns is deprecated. Use the MaxColumns property instead.")]
    public int GetMaxColumns()

Getter for MaxColumns

    [Obsolete("GetMaxTextLines is deprecated. Use the MaxTextLines property instead.")]
    public int GetMaxTextLines()

Getter for MaxTextLines

    public int[] GetSelectedItems()

Returns an array with the indexes of the selected items.

    [Obsolete("GetSelectMode is deprecated. Use the SelectMode property instead.")]
    public SelectModeEnum GetSelectMode()

Getter for SelectMode

    public VScrollBar GetVScroll()

Returns the Object ID associated with the list.

    [Obsolete("HasAutoHeight is deprecated. Use the AutoHeight property instead.")]
    public bool HasAutoHeight()

Getter for AutoHeight

    public bool IsAnythingSelected()

Returns true if one or more items are selected.

    public bool IsItemDisabled(int idx)

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

    public bool IsItemIconTransposed(int idx)

    public bool IsItemSelectable(int idx)

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

    public bool IsItemTooltipEnabled(int idx)

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

    [Obsolete("IsSameColumnWidth is deprecated. Use the SameColumnWidth property instead.")]
    public bool IsSameColumnWidth()

Getter for SameColumnWidth

    public bool IsSelected(int idx)

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

    public void MoveItem(int fromIdx, int toIdx)

Moves item from index fromIdx to toIdx.

    public void RemoveItem(int idx)

Removes the item specified by idx index from the list.

    public void Select(int idx, bool single = true)

Select the item at the specified index.

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

    [Obsolete("SetAllowReselect is deprecated. Use the AllowReselect property instead.")]
    public void SetAllowReselect(bool allow)

Setter for AllowReselect

    [Obsolete("SetAllowRmbSelect is deprecated. Use the AllowRmbSelect property instead.")]
    public void SetAllowRmbSelect(bool allow)

Setter for AllowRmbSelect

    [Obsolete("SetAutoHeight is deprecated. Use the AutoHeight property instead.")]
    public void SetAutoHeight(bool enable)

Setter for AutoHeight

    [Obsolete("SetFixedColumnWidth is deprecated. Use the FixedColumnWidth property instead.")]
    public void SetFixedColumnWidth(int width)

Setter for FixedColumnWidth

    [Obsolete("SetFixedIconSize is deprecated. Use the FixedIconSize property instead.")]
    public void SetFixedIconSize(Vector2 size)

Setter for FixedIconSize

    [Obsolete("SetIconMode is deprecated. Use the IconMode property instead.")]
    public void SetIconMode(IconModeEnum mode)

Setter for IconMode

    [Obsolete("SetIconScale is deprecated. Use the IconScale property instead.")]
    public void SetIconScale(float scale)

Setter for IconScale

    public void SetItemCustomBgColor(int idx, Color customBgColor)

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

[codeblock]

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.

[/codeblock]

    public void SetItemCustomFgColor(int idx, Color customFgColor)

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

[codeblock]

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.

[/codeblock]

    public void SetItemDisabled(int 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).

    public void SetItemIcon(int idx, Texture icon)

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

    public void SetItemIconModulate(int idx, Color modulate)

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

    public void SetItemIconRegion(int idx, Rect2 rect)

    public void SetItemIconTransposed(int idx, bool rect)

    public void SetItemMetadata(int idx, object metadata)

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

    public void SetItemSelectable(int idx, bool selectable)

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

    public void SetItemText(int idx, string text)

Sets text of the item associated with the specified index.

    public void SetItemTooltip(int idx, string tooltip)

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

    public void SetItemTooltipEnabled(int idx, bool enable)

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

    [Obsolete("SetMaxColumns is deprecated. Use the MaxColumns property instead.")]
    public void SetMaxColumns(int amount)

Setter for MaxColumns

    [Obsolete("SetMaxTextLines is deprecated. Use the MaxTextLines property instead.")]
    public void SetMaxTextLines(int lines)

Setter for MaxTextLines

    [Obsolete("SetSameColumnWidth is deprecated. Use the SameColumnWidth property instead.")]
    public void SetSameColumnWidth(bool enable)

Setter for SameColumnWidth

    [Obsolete("SetSelectMode is deprecated. Use the SelectMode property instead.")]
    public void SetSelectMode(SelectModeEnum mode)

Setter for SelectMode

    public void SortItemsByText()

Sorts items in the list by their text.

    public void Unselect(int idx)

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

    public void UnselectAll()

Ensures there are no items selected.

Inner Types

IconModeEnum

Name Value Description
Top 0  
Left 1  

SelectModeEnum

Name Value Description
Single 0 Only allow selecting a single item.
Multi 1 Allows selecting multiple items by holding Ctrl or Shift.
Tags: