ItemList

package
v0.0.0-...-7325ca5 Latest Latest
Warning

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

Go to latest
Published: Jan 31, 2025 License: MIT Imports: 26 Imported by: 0

Documentation

Overview

Package ItemList provides methods for working with ItemList object instances.

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 IconMode

type IconMode = gdclass.ItemListIconMode //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

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 [kbd]Enter[/kbd]. Item text only supports single-line strings. Newline characters (e.g. [code]\n[/code]) in the string won't produce a newline. Text wrapping is enabled in [constant ICON_MODE_TOP] mode, but the column's width is adjusted to fully fit its content by default. You need to set [member fixed_column_width] greater than zero to wrap the text. All [code]set_*[/code] methods allow negative item indices, i.e. [code]-1[/code] to access the last item, [code]-2[/code] to select the second-to-last item, and so on. [b]Incremental search:[/b] 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 [member ProjectSettings.gui/timers/incremental_search_max_interval_msec].

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 [1]gdclass.Texture2D) 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 [param icon], or use [code]null[/code] as the [param icon] for a list item with no icon. If selectable is [code]true[/code], 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) 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 [member auto_height], change. The method can be used to trigger the update ahead of next drawing pass.

func (Instance) GetItemAtPosition

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

Returns the item index at the given [param position]. When there is no item at that point, -1 will be returned if [param exact] is [code]true[/code], and the closest item index will be returned otherwise. [b]Note:[/b] The returned value is unreliable if called right after modifying the [ItemList], before it redraws in the next frame.

func (Instance) GetItemCustomBgColor

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

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

func (Instance) GetItemCustomFgColor

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

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

func (Instance) GetItemIcon

func (self Instance) GetItemIcon(idx int) [1]gdclass.Texture2D

Returns the icon associated with the specified index.

func (Instance) GetItemIconModulate

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

Returns a [Color] 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 [ItemList] node. If [param expand] is [code]true[/code] the last column expands to fill the rest of the row. [b]Note:[/b] The returned value is unreliable if called right after modifying the [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) gdclass.ControlTextDirection

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() [1]gdclass.VScrollBar

Returns the vertical scrollbar. [b]Warning:[/b] 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 [member CanvasItem.visible] property.

func (Instance) IconMode

func (self Instance) IconMode() gdclass.ItemListIconMode

func (Instance) IconScale

func (self Instance) IconScale() Float.X

func (Instance) IsAnythingSelected

func (self Instance) IsAnythingSelected() bool

Returns [code]true[/code] if one or more items are selected.

func (Instance) IsItemDisabled

func (self Instance) IsItemDisabled(idx int) bool

Returns [code]true[/code] if the item at the specified index is disabled.

func (Instance) IsItemIconTransposed

func (self Instance) IsItemIconTransposed(idx int) bool

Returns [code]true[/code] 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 [code]true[/code] if the item at the specified index is selectable.

func (Instance) IsItemTooltipEnabled

func (self Instance) IsItemTooltipEnabled(idx int) bool

Returns [code]true[/code] if the tooltip is enabled for specified item index.

func (Instance) IsSelected

func (self Instance) IsSelected(idx int) bool

Returns [code]true[/code] 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 [param from_idx] to [param to_idx].

func (Instance) OnEmptyClicked

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

func (Instance) OnItemActivated

func (self Instance) OnItemActivated(cb func(index int))

func (Instance) OnItemClicked

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

func (Instance) OnItemSelected

func (self Instance) OnItemSelected(cb func(index int))

func (Instance) OnMultiSelected

func (self Instance) OnMultiSelected(cb func(index int, selected bool))

func (Instance) RemoveItem

func (self Instance) RemoveItem(idx int)

Removes the item specified by [param 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. [b]Note:[/b] This method does not trigger the item selection signal.

func (Instance) SelectMode

func (self Instance) SelectMode() gdclass.ItemListSelectMode

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

func (Instance) SetIconScale

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

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 [param idx] index to the specified [Color].

func (Instance) SetItemCustomFgColor

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

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

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 [kbd]Enter[/kbd]).

func (Instance) SetItemIcon

func (self Instance) SetItemIcon(idx int, icon [1]gdclass.Texture2D)

Sets (or replaces) the icon's [Texture2D] associated with the specified index.

func (Instance) SetItemIconModulate

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

Sets a modulating [Color] 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 gdclass.ControlTextDirection)

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

func (self Instance) SetSameColumnWidth(value bool)

func (Instance) SetSelectMode

func (self Instance) SetSelectMode(value gdclass.ItemListSelectMode)

func (Instance) SetTextOverrunBehavior

func (self Instance) SetTextOverrunBehavior(value gdclass.TextServerOverrunBehavior)

func (Instance) SortItemsByText

func (self Instance) SortItemsByText()

Sorts items in the list by their text.

func (Instance) TextOverrunBehavior

func (self Instance) TextOverrunBehavior() gdclass.TextServerOverrunBehavior

func (*Instance) UnsafePointer

func (self *Instance) UnsafePointer() unsafe.Pointer

func (Instance) Virtual

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

type SelectMode

type SelectMode = gdclass.ItemListSelectMode //gd:ItemList.SelectMode
const (
	/*Only allow selecting a single item.*/
	SelectSingle SelectMode = 0
	/*Allows selecting multiple items by holding [kbd]Ctrl[/kbd] or [kbd]Shift[/kbd].*/
	SelectMulti SelectMode = 1
)

Jump to

Keyboard shortcuts

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