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 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 PopupMenu 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 ProjectSettings "gui/timers/incremental_search_max_interval_msec".
Index ¶
- type Advanced
- type Any
- type Expanded
- type Extension
- type ID
- type IconMode
- type Instance
- func (self Instance) AddIconItem(icon Texture2D.Instance) int
- func (self Instance) AddItem(text string) int
- func (self Instance) AllowReselect() bool
- func (self Instance) AllowRmbSelect() bool
- func (self Instance) AllowSearch() bool
- func (self Instance) AsCanvasItem() CanvasItem.Instance
- func (self Instance) AsControl() Control.Instance
- func (self Instance) AsItemList() Instance
- func (self Instance) AsNode() Node.Instance
- func (self Instance) AsObject() [1]gd.Object
- func (self Instance) AutoHeight() bool
- func (self Instance) AutoWidth() bool
- func (self Instance) Clear()
- func (self Instance) Deselect(idx int)
- func (self Instance) DeselectAll()
- func (self Instance) EnsureCurrentIsVisible()
- func (self Instance) FixedColumnWidth() int
- func (self Instance) FixedIconSize() Vector2i.XY
- func (self Instance) ForceUpdateListSize()
- func (self Instance) GetHScrollBar() HScrollBar.Instance
- func (self Instance) GetItemAtPosition(position Vector2.XY) int
- func (self Instance) GetItemAutoTranslateMode(idx int) Node.AutoTranslateMode
- func (self Instance) GetItemCustomBgColor(idx int) Color.RGBA
- func (self Instance) GetItemCustomFgColor(idx int) Color.RGBA
- func (self Instance) GetItemIcon(idx int) Texture2D.Instance
- func (self Instance) GetItemIconModulate(idx int) Color.RGBA
- func (self Instance) GetItemIconRegion(idx int) Rect2.PositionSize
- func (self Instance) GetItemLanguage(idx int) string
- func (self Instance) GetItemMetadata(idx int) any
- func (self Instance) GetItemRect(idx int) Rect2.PositionSize
- func (self Instance) GetItemText(idx int) string
- func (self Instance) GetItemTextDirection(idx int) Control.TextDirection
- func (self Instance) GetItemTooltip(idx int) string
- func (self Instance) GetSelectedItems() []int32
- func (self Instance) GetVScrollBar() VScrollBar.Instance
- func (self Instance) ID() ID
- func (self Instance) IconMode() IconMode
- func (self Instance) IconScale() Float.X
- func (self Instance) IsAnythingSelected() bool
- func (self Instance) IsItemDisabled(idx int) bool
- func (self Instance) IsItemIconTransposed(idx int) bool
- func (self Instance) IsItemSelectable(idx int) bool
- func (self Instance) IsItemTooltipEnabled(idx int) bool
- func (self Instance) IsSelected(idx int) bool
- func (self Instance) ItemCount() int
- func (self Instance) MaxColumns() int
- func (self Instance) MaxTextLines() int
- func (self Instance) MoreArgs() MoreArgs
- func (self Instance) MoveItem(from_idx int, to_idx int)
- func (self Instance) OnEmptyClicked(cb func(at_position Vector2.XY, mouse_button_index int), flags ...Signal.Flags)
- func (self Instance) OnItemActivated(cb func(index int), flags ...Signal.Flags)
- func (self Instance) OnItemClicked(cb func(index int, at_position Vector2.XY, mouse_button_index int), ...)
- func (self Instance) OnItemSelected(cb func(index int), flags ...Signal.Flags)
- func (self Instance) OnMultiSelected(cb func(index int, selected bool), flags ...Signal.Flags)
- func (self Instance) RemoveItem(idx int)
- func (self Instance) SameColumnWidth() bool
- func (self Instance) Select(idx int)
- func (self Instance) SelectMode() SelectMode
- func (self Instance) SetAllowReselect(value bool)
- func (self Instance) SetAllowRmbSelect(value bool)
- func (self Instance) SetAllowSearch(value bool)
- func (self Instance) SetAutoHeight(value bool)
- func (self Instance) SetAutoWidth(value bool)
- func (self Instance) SetFixedColumnWidth(value int)
- func (self Instance) SetFixedIconSize(value Vector2i.XY)
- func (self Instance) SetIconMode(value IconMode)
- func (self Instance) SetIconScale(value Float.X)
- func (self Instance) SetItemAutoTranslateMode(idx int, mode Node.AutoTranslateMode)
- func (self Instance) SetItemCount(value int)
- func (self Instance) SetItemCustomBgColor(idx int, custom_bg_color Color.RGBA)
- func (self Instance) SetItemCustomFgColor(idx int, custom_fg_color Color.RGBA)
- func (self Instance) SetItemDisabled(idx int, disabled bool)
- func (self Instance) SetItemIcon(idx int, icon Texture2D.Instance)
- func (self Instance) SetItemIconModulate(idx int, modulate Color.RGBA)
- func (self Instance) SetItemIconRegion(idx int, rect Rect2.PositionSize)
- func (self Instance) SetItemIconTransposed(idx int, transposed bool)
- func (self Instance) SetItemLanguage(idx int, language string)
- func (self Instance) SetItemMetadata(idx int, metadata any)
- func (self Instance) SetItemSelectable(idx int, selectable bool)
- func (self Instance) SetItemText(idx int, text string)
- func (self Instance) SetItemTextDirection(idx int, direction Control.TextDirection)
- func (self Instance) SetItemTooltip(idx int, tooltip string)
- func (self Instance) SetItemTooltipEnabled(idx int, enable bool)
- func (self Instance) SetMaxColumns(value int)
- func (self Instance) SetMaxTextLines(value int)
- func (self *Instance) SetObject(obj [1]gd.Object) bool
- func (self Instance) SetSameColumnWidth(value bool)
- func (self Instance) SetSelectMode(value SelectMode)
- func (self Instance) SetTextOverrunBehavior(value TextServer.OverrunBehavior)
- func (self Instance) SetWraparoundItems(value bool)
- func (self Instance) SortItemsByText()
- func (self Instance) TextOverrunBehavior() TextServer.OverrunBehavior
- func (self Instance) Virtual(name string) reflect.Value
- func (self Instance) WraparoundItems() bool
- type MoreArgs
- func (self MoreArgs) AddIconItem(icon Texture2D.Instance, selectable bool) int
- func (self MoreArgs) AddItem(text string, icon Texture2D.Instance, selectable bool) int
- func (self MoreArgs) GetItemAtPosition(position Vector2.XY, exact bool) int
- func (self MoreArgs) GetItemRect(idx int, expand bool) Rect2.PositionSize
- func (self MoreArgs) Select(idx int, single bool)
- type SelectMode
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 Extension ¶
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]) AsItemList ¶
type 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.
type Instance ¶
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 (Instance) AddIconItem ¶
Adds an item to the item list with no text, only an icon. Returns the index of an added item.
func (Instance) AddItem ¶
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 ¶
If true, the currently selected item can be selected again.
func (Instance) AllowRmbSelect ¶
If true, right mouse button click can select items.
func (Instance) AllowSearch ¶
If true, allows navigating the ItemList with letter keys through incremental search.
func (Instance) AsCanvasItem ¶
func (self Instance) AsCanvasItem() CanvasItem.Instance
func (Instance) AsItemList ¶
func (Instance) AutoHeight ¶
If true, the control will automatically resize the height to fit its content.
func (Instance) AutoWidth ¶
If true, the control will automatically resize the width to fit its content.
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 ¶
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.
func (Instance) FixedIconSize ¶
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.
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 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 CanvasItem.Visible property.
func (Instance) GetItemAtPosition ¶
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 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 ¶
Returns the custom background color of the item specified by 'idx' index.
func (Instance) GetItemCustomFgColor ¶
Returns the custom foreground color of the item specified by 'idx' index.
func (Instance) GetItemIcon ¶
Returns the icon associated with the specified index.
func (Instance) GetItemIconModulate ¶
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 ¶
Returns item's text language code.
func (Instance) GetItemMetadata ¶
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 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 ItemList, before it redraws in the next frame.
func (Instance) GetItemText ¶
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 ¶
Returns the tooltip hint associated with the specified index.
func (Instance) GetSelectedItems ¶
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 CanvasItem.Visible property.
func (Instance) IconMode ¶
The icon position, whether above or to the left of the text. See the IconMode constants.
func (Instance) IconScale ¶
The scale of icon applied after FixedIconSize and transposing takes effect.
func (Instance) IsAnythingSelected ¶
Returns true if one or more items are selected.
func (Instance) IsItemDisabled ¶
Returns true if the item at the specified index is disabled.
func (Instance) IsItemIconTransposed ¶
Returns true if the item icon will be drawn transposed, i.e. the X and Y axes are swapped.
func (Instance) IsItemSelectable ¶
Returns true if the item at the specified index is selectable.
func (Instance) IsItemTooltipEnabled ¶
Returns true if the tooltip is enabled for specified item index.
func (Instance) IsSelected ¶
Returns true if the item at the specified index is currently selected.
func (Instance) MaxColumns ¶
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.
func (Instance) MaxTextLines ¶
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 IconMode is IconModeTop. To make the text wrap, FixedColumnWidth should be greater than zero.
func (Instance) MoreArgs ¶
MoreArgs enables certain functions to be called with additional 'optional' arguments.
func (Instance) OnEmptyClicked ¶
func (self Instance) OnEmptyClicked(cb func(at_position Vector2.XY, mouse_button_index int), flags ...Signal.Flags)
Emitted when any mouse click is issued within the rect of the list but on empty space.
'at_position' is the click position in this control's local coordinate system.
func (Instance) OnItemActivated ¶
Emitted when specified list item is activated via double-clicking or by pressing Enter.
func (Instance) OnItemClicked ¶
func (self Instance) OnItemClicked(cb func(index int, at_position Vector2.XY, mouse_button_index int), flags ...Signal.Flags)
Emitted when specified list item has been clicked with any mouse button.
'at_position' is the click position in this control's local coordinate system.
func (Instance) OnItemSelected ¶
Emitted when specified item has been selected. Only applicable in single selection mode.
AllowReselect must be enabled to reselect an item.
func (Instance) OnMultiSelected ¶
Emitted when a multiple selection is altered on a list allowing multiple selection.
func (Instance) RemoveItem ¶
Removes the item specified by 'idx' index from the list.
func (Instance) SameColumnWidth ¶
Whether all columns will have the same width.
If true, the width is equal to the largest column width of all columns.
func (Instance) Select ¶
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
Allows single or multiple item selection. See the SelectMode constants.
func (Instance) SetAllowReselect ¶
SetAllowReselect sets the property returned by [GetAllowReselect].
func (Instance) SetAllowRmbSelect ¶
SetAllowRmbSelect sets the property returned by [GetAllowRmbSelect].
func (Instance) SetAllowSearch ¶
SetAllowSearch sets the property returned by [GetAllowSearch].
func (Instance) SetAutoHeight ¶
SetAutoHeight sets the property returned by [HasAutoHeight].
func (Instance) SetAutoWidth ¶
SetAutoWidth sets the property returned by [HasAutoWidth].
func (Instance) SetFixedColumnWidth ¶
SetFixedColumnWidth sets the property returned by [GetFixedColumnWidth].
func (Instance) SetFixedIconSize ¶
SetFixedIconSize sets the property returned by [GetFixedIconSize].
func (Instance) SetIconMode ¶
SetIconMode sets the property returned by [GetIconMode].
func (Instance) SetIconScale ¶
SetIconScale sets the property returned by [GetIconScale].
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 ItemList itself.
func (Instance) SetItemCount ¶
SetItemCount sets the property returned by [GetItemCount].
func (Instance) SetItemCustomBgColor ¶
Sets the background color of the item specified by 'idx' index to the specified Color.RGBA.
func (Instance) SetItemCustomFgColor ¶
Sets the foreground color of the item specified by 'idx' index to the specified Color.RGBA.
func (Instance) SetItemDisabled ¶
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 ¶
Sets (or replaces) the icon's Texture2D associated with the specified index.
func (Instance) SetItemIconModulate ¶
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 ¶
Sets whether the item icon will be drawn transposed.
func (Instance) SetItemLanguage ¶
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 ¶
Sets a value (of any type) to be stored with the item associated with the specified index.
func (Instance) SetItemSelectable ¶
Allows or disallows selection of the item associated with the specified index.
func (Instance) SetItemText ¶
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 ¶
Sets the tooltip hint for the item associated with the specified index.
func (Instance) SetItemTooltipEnabled ¶
Sets whether the tooltip hint is enabled for specified item index.
func (Instance) SetMaxColumns ¶
SetMaxColumns sets the property returned by [GetMaxColumns].
func (Instance) SetMaxTextLines ¶
SetMaxTextLines sets the property returned by [GetMaxTextLines].
func (Instance) SetSameColumnWidth ¶
SetSameColumnWidth sets the property returned by [IsSameColumnWidth].
func (Instance) SetSelectMode ¶
func (self Instance) SetSelectMode(value SelectMode)
SetSelectMode sets the property returned by [GetSelectMode].
func (Instance) SetTextOverrunBehavior ¶
func (self Instance) SetTextOverrunBehavior(value TextServer.OverrunBehavior)
SetTextOverrunBehavior sets the property returned by [GetTextOverrunBehavior].
func (Instance) SetWraparoundItems ¶
SetWraparoundItems sets the property returned by [HasWraparoundItems].
func (Instance) SortItemsByText ¶
func (self Instance) SortItemsByText()
Sorts items in the list by their text.
func (Instance) TextOverrunBehavior ¶
func (self Instance) TextOverrunBehavior() TextServer.OverrunBehavior
The clipping behavior when the text exceeds an item's bounding rectangle.
func (Instance) WraparoundItems ¶
If true, the control will automatically move items into a new row to fit its content. See also HFlowContainer for this behavior.
If false, the control will add a horizontal scrollbar to make all items visible.
type MoreArgs ¶
MoreArgs is a container for Instance functions with additional 'optional' arguments.
func (MoreArgs) AddIconItem ¶
Adds an item to the item list with no text, only an icon. Returns the index of an added item.
func (MoreArgs) AddItem ¶
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 (MoreArgs) GetItemAtPosition ¶
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 ItemList, before it redraws in the next frame.
func (MoreArgs) GetItemRect ¶
func (self MoreArgs) 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 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 ItemList, before it redraws in the next frame.
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 )