ItemList

package
v0.0.0-...-0d6c339 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 16, 2025 License: MIT Imports: 33 Imported by: 0

Documentation

Overview

This control provides a vertical list of selectable items that may be in a single or in multiple columns, with each item having options for text and an 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 IconModeTop mode, but the column's width is adjusted to fully fit its content by default. You need to set Instance.FixedColumnWidth greater than zero to wrap the text.

All set_* methods allow negative item indices, i.e. -1 to access the last item, -2 to select the second-to-last item, and so on.

Incremental search: Like graphics.gd/classdb/PopupMenu and graphics.gd/classdb/Tree, graphics.gd/classdb/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 graphics.gd/classdb/ProjectSettings "gui/timers/incremental_search_max_interval_msec".

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Advanced

type Advanced = class

Advanced exposes a 1:1 low-level instance of the class, undocumented, for those who know what they are doing.

type Any

type Any interface {
	gd.IsClass
	AsItemList() Instance
}

type Expanded

type Expanded [1]gdclass.ItemList

func (Expanded) AddIconItem

func (self Expanded) AddIconItem(icon Texture2D.Instance, selectable bool) int

Adds an item to the item list with no text, only an icon. Returns the index of an added item.

func (Expanded) AddItem

func (self Expanded) AddItem(text string, icon Texture2D.Instance, selectable bool) int

Adds an item to the item list with specified text. Returns the index of an added item.

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.

func (Expanded) GetItemAtPosition

func (self Expanded) GetItemAtPosition(position Vector2.XY, exact bool) int

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.

Note: The returned value is unreliable if called right after modifying the graphics.gd/classdb/ItemList, before it redraws in the next frame.

func (Expanded) GetItemRect

func (self Expanded) GetItemRect(idx int, expand bool) Rect2.PositionSize

Returns the position and size of the item with the specified index, in the coordinate system of the graphics.gd/classdb/ItemList node. If 'expand' is true the last column expands to fill the rest of the row.

Note: The returned value is unreliable if called right after modifying the graphics.gd/classdb/ItemList, before it redraws in the next frame.

func (Expanded) Select

func (self Expanded) Select(idx int, single bool)

Select the item at the specified index.

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

type Extension

type Extension[T gdclass.Interface] struct{ gdclass.Extension[T, Instance] }

Extension can be embedded in a new struct to create an extension of this class. T should be the type that is embedding this Extension

func (*Extension[T]) AsCanvasItem

func (self *Extension[T]) AsCanvasItem() CanvasItem.Instance

func (*Extension[T]) AsControl

func (self *Extension[T]) AsControl() Control.Instance

func (*Extension[T]) AsItemList

func (self *Extension[T]) AsItemList() Instance

func (*Extension[T]) AsNode

func (self *Extension[T]) AsNode() Node.Instance

func (*Extension[T]) AsObject

func (self *Extension[T]) AsObject() [1]gd.Object

type ID

type ID Object.ID

ID is a typed object ID (reference) to an instance of this class, use it to store references to objects with unknown lifetimes, as an ID will not panic on use if the underlying object has been destroyed.

func (ID) Instance

func (id ID) Instance() (Instance, bool)

type IconMode

type IconMode int //gd:ItemList.IconMode
const (
	// Icon is drawn above the text.
	IconModeTop IconMode = 0
	// Icon is drawn to the left of the text.
	IconModeLeft IconMode = 1
)

type Instance

type Instance [1]gdclass.ItemList

Instance of the class with convieniently typed arguments and results.

var Nil Instance

Nil is a nil/null instance of the class. Equivalent to the zero value.

func New

func New() Instance

func (Instance) AddIconItem

func (self Instance) AddIconItem(icon Texture2D.Instance) int

Adds an item to the item list with no text, only an icon. Returns the index of an added item.

func (Instance) AddItem

func (self Instance) AddItem(text string) int

Adds an item to the item list with specified text. Returns the index of an added item.

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.

func (Instance) AllowReselect

func (self Instance) AllowReselect() bool

func (Instance) AllowRmbSelect

func (self Instance) AllowRmbSelect() bool

func (Instance) AllowSearch

func (self Instance) AllowSearch() bool

func (Instance) AsCanvasItem

func (self Instance) AsCanvasItem() CanvasItem.Instance

func (Instance) AsControl

func (self Instance) AsControl() Control.Instance

func (Instance) AsItemList

func (self Instance) AsItemList() Instance

func (Instance) AsNode

func (self Instance) AsNode() Node.Instance

func (Instance) AsObject

func (self Instance) AsObject() [1]gd.Object

func (Instance) AutoHeight

func (self Instance) AutoHeight() bool

func (Instance) AutoWidth

func (self Instance) AutoWidth() bool

func (Instance) Clear

func (self Instance) Clear()

Removes all items from the list.

func (Instance) Deselect

func (self Instance) Deselect(idx int)

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

func (Instance) DeselectAll

func (self Instance) DeselectAll()

Ensures there are no items selected.

func (Instance) EnsureCurrentIsVisible

func (self Instance) EnsureCurrentIsVisible()

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

func (Instance) FixedColumnWidth

func (self Instance) FixedColumnWidth() int

func (Instance) FixedIconSize

func (self Instance) FixedIconSize() Vector2i.XY

func (Instance) ForceUpdateListSize

func (self Instance) ForceUpdateListSize()

Forces an update to the list size based on its items. This happens automatically whenever size of the items, or other relevant settings like Instance.AutoHeight, change. The method can be used to trigger the update ahead of next drawing pass.

func (Instance) GetHScrollBar

func (self Instance) GetHScrollBar() HScrollBar.Instance

Returns the horizontal 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 graphics.gd/classdb/CanvasItem.Instance.Visible property.

func (Instance) GetItemAtPosition

func (self Instance) GetItemAtPosition(position Vector2.XY) int

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.

Note: The returned value is unreliable if called right after modifying the graphics.gd/classdb/ItemList, before it redraws in the next frame.

func (Instance) GetItemAutoTranslateMode

func (self Instance) GetItemAutoTranslateMode(idx int) Node.AutoTranslateMode

Returns item's auto translate mode.

func (Instance) GetItemCustomBgColor

func (self Instance) GetItemCustomBgColor(idx int) Color.RGBA

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

func (Instance) GetItemCustomFgColor

func (self Instance) GetItemCustomFgColor(idx int) Color.RGBA

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

func (Instance) GetItemIcon

func (self Instance) GetItemIcon(idx int) Texture2D.Instance

Returns the icon associated with the specified index.

func (Instance) GetItemIconModulate

func (self Instance) GetItemIconModulate(idx int) Color.RGBA

Returns a [Color.RGBA] modulating item's icon at the specified index.

func (Instance) GetItemIconRegion

func (self Instance) GetItemIconRegion(idx int) Rect2.PositionSize

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

func (Instance) GetItemLanguage

func (self Instance) GetItemLanguage(idx int) string

Returns item's text language code.

func (Instance) GetItemMetadata

func (self Instance) GetItemMetadata(idx int) any

Returns the metadata value of the specified index.

func (Instance) GetItemRect

func (self Instance) GetItemRect(idx int) Rect2.PositionSize

Returns the position and size of the item with the specified index, in the coordinate system of the graphics.gd/classdb/ItemList node. If 'expand' is true the last column expands to fill the rest of the row.

Note: The returned value is unreliable if called right after modifying the graphics.gd/classdb/ItemList, before it redraws in the next frame.

func (Instance) GetItemText

func (self Instance) GetItemText(idx int) string

Returns the text associated with the specified index.

func (Instance) GetItemTextDirection

func (self Instance) GetItemTextDirection(idx int) Control.TextDirection

Returns item's text base writing direction.

func (Instance) GetItemTooltip

func (self Instance) GetItemTooltip(idx int) string

Returns the tooltip hint associated with the specified index.

func (Instance) GetSelectedItems

func (self Instance) GetSelectedItems() []int32

Returns an array with the indexes of the selected items.

func (Instance) GetVScrollBar

func (self Instance) GetVScrollBar() VScrollBar.Instance

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 graphics.gd/classdb/CanvasItem.Instance.Visible property.

func (Instance) ID

func (self Instance) ID() ID

func (Instance) IconMode

func (self Instance) IconMode() IconMode

func (Instance) IconScale

func (self Instance) IconScale() Float.X

func (Instance) IsAnythingSelected

func (self Instance) IsAnythingSelected() bool

Returns true if one or more items are selected.

func (Instance) IsItemDisabled

func (self Instance) IsItemDisabled(idx int) bool

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

func (Instance) IsItemIconTransposed

func (self Instance) IsItemIconTransposed(idx int) bool

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

func (Instance) IsItemSelectable

func (self Instance) IsItemSelectable(idx int) bool

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

func (Instance) IsItemTooltipEnabled

func (self Instance) IsItemTooltipEnabled(idx int) bool

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

func (Instance) IsSelected

func (self Instance) IsSelected(idx int) bool

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

func (Instance) ItemCount

func (self Instance) ItemCount() int

func (Instance) MaxColumns

func (self Instance) MaxColumns() int

func (Instance) MaxTextLines

func (self Instance) MaxTextLines() int

func (Instance) MoveItem

func (self Instance) MoveItem(from_idx int, to_idx int)

Moves item from index 'from_idx' to 'to_idx'.

func (Instance) OnEmptyClicked

func (self Instance) OnEmptyClicked(cb func(at_position Vector2.XY, mouse_button_index int), flags ...Signal.Flags)

func (Instance) OnItemActivated

func (self Instance) OnItemActivated(cb func(index int), flags ...Signal.Flags)

func (Instance) OnItemClicked

func (self Instance) OnItemClicked(cb func(index int, at_position Vector2.XY, mouse_button_index int), flags ...Signal.Flags)

func (Instance) OnItemSelected

func (self Instance) OnItemSelected(cb func(index int), flags ...Signal.Flags)

func (Instance) OnMultiSelected

func (self Instance) OnMultiSelected(cb func(index int, selected bool), flags ...Signal.Flags)

func (Instance) RemoveItem

func (self Instance) RemoveItem(idx int)

Removes the item specified by 'idx' index from the list.

func (Instance) SameColumnWidth

func (self Instance) SameColumnWidth() bool

func (Instance) Select

func (self Instance) Select(idx int)

Select the item at the specified index.

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

func (Instance) SelectMode

func (self Instance) SelectMode() SelectMode

func (Instance) SetAllowReselect

func (self Instance) SetAllowReselect(value bool)

func (Instance) SetAllowRmbSelect

func (self Instance) SetAllowRmbSelect(value bool)

func (Instance) SetAllowSearch

func (self Instance) SetAllowSearch(value bool)

func (Instance) SetAutoHeight

func (self Instance) SetAutoHeight(value bool)

func (Instance) SetAutoWidth

func (self Instance) SetAutoWidth(value bool)

func (Instance) SetFixedColumnWidth

func (self Instance) SetFixedColumnWidth(value int)

func (Instance) SetFixedIconSize

func (self Instance) SetFixedIconSize(value Vector2i.XY)

func (Instance) SetIconMode

func (self Instance) SetIconMode(value IconMode)

func (Instance) SetIconScale

func (self Instance) SetIconScale(value Float.X)

func (Instance) SetItemAutoTranslateMode

func (self Instance) SetItemAutoTranslateMode(idx int, mode Node.AutoTranslateMode)

Sets the auto translate mode of the item associated with the specified index.

Items use [Node.AutoTranslateModeInherit] by default, which uses the same auto translate mode as the graphics.gd/classdb/ItemList itself.

func (Instance) SetItemCount

func (self Instance) SetItemCount(value int)

func (Instance) SetItemCustomBgColor

func (self Instance) SetItemCustomBgColor(idx int, custom_bg_color Color.RGBA)

Sets the background color of the item specified by 'idx' index to the specified [Color.RGBA].

func (Instance) SetItemCustomFgColor

func (self Instance) SetItemCustomFgColor(idx int, custom_fg_color Color.RGBA)

Sets the foreground color of the item specified by 'idx' index to the specified [Color.RGBA].

func (Instance) SetItemDisabled

func (self Instance) SetItemDisabled(idx int, disabled bool)

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

func (Instance) SetItemIcon

func (self Instance) SetItemIcon(idx int, icon Texture2D.Instance)

Sets (or replaces) the icon's graphics.gd/classdb/Texture2D associated with the specified index.

func (Instance) SetItemIconModulate

func (self Instance) SetItemIconModulate(idx int, modulate Color.RGBA)

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

func (Instance) SetItemIconRegion

func (self Instance) SetItemIconRegion(idx int, rect Rect2.PositionSize)

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

func (Instance) SetItemIconTransposed

func (self Instance) SetItemIconTransposed(idx int, transposed bool)

Sets whether the item icon will be drawn transposed.

func (Instance) SetItemLanguage

func (self Instance) SetItemLanguage(idx int, language string)

Sets language code of item's text used for line-breaking and text shaping algorithms, if left empty current locale is used instead.

func (Instance) SetItemMetadata

func (self Instance) SetItemMetadata(idx int, metadata any)

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

func (Instance) SetItemSelectable

func (self Instance) SetItemSelectable(idx int, selectable bool)

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

func (Instance) SetItemText

func (self Instance) SetItemText(idx int, text string)

Sets text of the item associated with the specified index.

func (Instance) SetItemTextDirection

func (self Instance) SetItemTextDirection(idx int, direction Control.TextDirection)

Sets item's text base writing direction.

func (Instance) SetItemTooltip

func (self Instance) SetItemTooltip(idx int, tooltip string)

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

func (Instance) SetItemTooltipEnabled

func (self Instance) SetItemTooltipEnabled(idx int, enable bool)

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

func (Instance) SetMaxColumns

func (self Instance) SetMaxColumns(value int)

func (Instance) SetMaxTextLines

func (self Instance) SetMaxTextLines(value int)

func (*Instance) SetObject

func (self *Instance) SetObject(obj [1]gd.Object) bool

func (Instance) SetSameColumnWidth

func (self Instance) SetSameColumnWidth(value bool)

func (Instance) SetSelectMode

func (self Instance) SetSelectMode(value SelectMode)

func (Instance) SetTextOverrunBehavior

func (self Instance) SetTextOverrunBehavior(value TextServer.OverrunBehavior)

func (Instance) SetWraparoundItems

func (self Instance) SetWraparoundItems(value bool)

func (Instance) SortItemsByText

func (self Instance) SortItemsByText()

Sorts items in the list by their text.

func (Instance) TextOverrunBehavior

func (self Instance) TextOverrunBehavior() TextServer.OverrunBehavior

func (Instance) Virtual

func (self Instance) Virtual(name string) reflect.Value

func (Instance) WraparoundItems

func (self Instance) WraparoundItems() bool

type SelectMode

type SelectMode int //gd:ItemList.SelectMode
const (
	// Only allow selecting a single item.
	SelectSingle SelectMode = 0
	// Allows selecting multiple items by holding Ctrl or Shift.
	SelectMulti SelectMode = 1
	// Allows selecting multiple items by toggling them on and off.
	SelectToggle SelectMode = 2
)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL