Skip to content

ItemList

Eduard Gushchin edited this page Jul 1, 2026 · 3 revisions

Home | API by Category | Complete API Index | API Compatibility

Field Value
Full name Electron2D.ItemList
Namespace Electron2D
Kind class
Category UI and Text

Overview

Displays a selectable flat list of text and optional icon items.

Syntax

public class Electron2D.ItemList : Electron2D.Control

Godot 4.7 C# profile compatibility

Profile: Electron2D 0.1.0 2D
Status: Supported / Parity verified
Out of profile: no
Godot reference: ItemList

Flat selectable UI list with item text, optional icons, disabled/selectable flags, single/multi selection, pointer activation and selection signals.

Remarks

ItemList is a runtime UI control for menus, inspectors and debug panels that need a compact list of selectable rows.

The 0.1.0 Preview implementation supports item storage, single and multi selection, pointer activation, keyboard activation and simple canvas drawing. Scrolling and text search are reserved for later UI tasks.

Thread Safety

This type is not synchronized. Create and mutate item lists on the main scene thread.

Since

This type is available since Electron2D 0.1.0 Preview.

See Also

  • Electron2D.Control
  • Electron2D.PopupMenu

Members

Member Kind Summary
AllowReselect Property Gets or sets whether selecting the current item again still emits signals.
AllowRmbSelect Property Gets or sets whether right mouse button input may select rows.
FixedColumnWidth Property Gets or sets the requested fixed column width.
FixedIconSize Property Gets or sets the requested fixed icon size.
ItemCount Property Gets the number of items stored in this list.
MaxColumns Property Gets or sets the maximum number of visual columns requested by the list.
SelectMode Property Gets or sets the selection mode used by this list.
Electron2D.ItemList() Constructor Initializes a new instance of the Electron2D.ItemList class.
AddIconItem(Electron2D.Texture2D, System.Boolean) Method Adds an item that displays only an icon.
AddItem(System.String, Electron2D.Texture2D, System.Boolean) Method Adds an item with optional text and icon.
Clear() Method Removes every item and clears selection.
Deselect(System.Int32) Method Clears selection from one item.
DeselectAll() Method Clears selection from every item.
GetItemAtPosition(Electron2D.Vector2, System.Boolean) Method Gets the item index at a local position.
GetItemCount() Method Gets the number of stored items.
GetItemIcon(System.Int32) Method Gets the icon displayed by an item.
GetItemText(System.Int32) Method Gets the text displayed by an item.
GetSelectedItems() Method Gets the indices of selected items.
IsItemDisabled(System.Int32) Method Reports whether an item is disabled.
IsItemSelectable(System.Int32) Method Reports whether an item can be selected.
IsSelected(System.Int32) Method Reports whether an item is selected.
Select(System.Int32, System.Boolean) Method Selects an item.
SetItemDisabled(System.Int32, System.Boolean) Method Sets whether an item ignores user selection and activation.
SetItemIcon(System.Int32, Electron2D.Texture2D) Method Sets the icon displayed by an item.
SetItemSelectable(System.Int32, System.Boolean) Method Sets whether an item can be selected.
SetItemText(System.Int32, System.String) Method Sets the text displayed by an item.
_Draw() Method Draws the list rows, selection backgrounds and text.
_GetMinimumSize() Method Gets the minimum size requested by this list.
_GuiInput(Electron2D.InputEvent) Method Handles GUI input routed to this list.

Member Details

AllowReselect

Kind: Property

public System.Boolean AllowReselect { get; set; }

Summary

Gets or sets whether selecting the current item again still emits signals.

Remarks

This property affects user input and Electron2D.ItemList.Select(System.Int32,System.Boolean).

Value

true to emit selection signals for already selected items; otherwise, false.

Thread Safety

This property is not synchronized. Mutate it on the main scene thread.

Since

This property is available since Electron2D 0.1.0 Preview.

See Also

  • Electron2D.ItemList.Select(System.Int32,System.Boolean)

AllowRmbSelect

Kind: Property

public System.Boolean AllowRmbSelect { get; set; }

Summary

Gets or sets whether right mouse button input may select rows.

Remarks

Right-click activation is useful for context menus. The preview still emits normal selection signals when selection succeeds.

Value

true to allow right-click selection; otherwise, false.

Thread Safety

This property is not synchronized. Mutate it on the main scene thread.

Since

This property is available since Electron2D 0.1.0 Preview.

See Also

  • Electron2D.ItemList._GuiInput(Electron2D.InputEvent)

FixedColumnWidth

Kind: Property

public System.Int32 FixedColumnWidth { get; set; }

Summary

Gets or sets the requested fixed column width.

Remarks

The preview drawing path stores the value and keeps row hit-testing simple.

Value

0 for automatic width, or a positive width in UI units.

Exceptions

  • System.ArgumentOutOfRangeException: Thrown when the assigned value is negative.

Thread Safety

This property is not synchronized. Mutate it on the main scene thread.

Since

This property is available since Electron2D 0.1.0 Preview.

See Also

  • Electron2D.ItemList.MaxColumns

FixedIconSize

Kind: Property

public Electron2D.Vector2I FixedIconSize { get; set; }

Summary

Gets or sets the requested fixed icon size.

Remarks

The preview stores this value and uses it for minimum-size estimation.

Value

A non-negative icon size. Electron2D.Vector2I.Zero means icons use their resource size.

Exceptions

  • System.ArgumentOutOfRangeException: Thrown when any component is negative.

Thread Safety

This property is not synchronized. Mutate it on the main scene thread.

Since

This property is available since Electron2D 0.1.0 Preview.

See Also

  • Electron2D.Texture2D.GetSize

ItemCount

Kind: Property

public System.Int32 ItemCount { get; }

Summary

Gets the number of items stored in this list.

Remarks

The value changes through Electron2D.ItemList.AddItem(System.String,Electron2D.Texture2D,System.Boolean), Electron2D.ItemList.AddIconItem(Electron2D.Texture2D,System.Boolean) and Electron2D.ItemList.Clear.

Value

The current item count.

Thread Safety

This property is not synchronized. Read it on the main scene thread.

Since

This property is available since Electron2D 0.1.0 Preview.

See Also

  • Electron2D.ItemList.GetItemCount

MaxColumns

Kind: Property

public System.Int32 MaxColumns { get; set; }

Summary

Gets or sets the maximum number of visual columns requested by the list.

Remarks

The 0.1.0 Preview stores this value for layout consumers. Pointer hit-testing remains row-based.

Value

A positive number of columns. The default is 1.

Exceptions

  • System.ArgumentOutOfRangeException: Thrown when the assigned value is less than 1.

Thread Safety

This property is not synchronized. Mutate it on the main scene thread.

Since

This property is available since Electron2D 0.1.0 Preview.

See Also

  • Electron2D.ItemList.FixedColumnWidth

SelectMode

Kind: Property

public Electron2D.ItemList.SelectModeEnum SelectMode { get; set; }

Summary

Gets or sets the selection mode used by this list.

Remarks

Changing from multi selection to single selection keeps the first selected item and clears the rest.

Value

The current Electron2D.ItemList.SelectModeEnum. The default is Electron2D.ItemList.SelectModeEnum.Single.

Thread Safety

This property is not synchronized. Mutate it on the main scene thread.

Since

This property is available since Electron2D 0.1.0 Preview.

See Also

  • Electron2D.ItemList.Select(System.Int32,System.Boolean)

Electron2D.ItemList()

Kind: Constructor

public Electron2D.ItemList()

Summary

Initializes a new instance of the Electron2D.ItemList class.

Remarks

The constructor enables focus and registers item_selected, multi_selected and item_activated signals.

Thread Safety

This constructor is not synchronized. Call it from the main scene thread.

Since

This constructor is available since Electron2D 0.1.0 Preview.

See Also

  • Electron2D.ItemList

AddIconItem(Electron2D.Texture2D, System.Boolean)

Kind: Method

public System.Int32 AddIconItem(Electron2D.Texture2D, System.Boolean)(Electron2D.Texture2D icon, System.Boolean selectable)

Summary

Adds an item that displays only an icon.

Remarks

This is equivalent to adding an item with empty text and the specified icon.

Parameters

  • icon: The icon texture to display.
  • selectable: Whether the item can be selected.

Returns

The zero-based index of the created item.

Exceptions

  • System.ArgumentNullException: Thrown when icon is null.

Thread Safety

This method is not synchronized. Call it on the main scene thread.

Since

This method is available since Electron2D 0.1.0 Preview.

See Also

  • Electron2D.ItemList.AddItem(System.String,Electron2D.Texture2D,System.Boolean)

AddItem(System.String, Electron2D.Texture2D, System.Boolean)

Kind: Method

public System.Int32 AddItem(System.String, Electron2D.Texture2D, System.Boolean)(System.String text, Electron2D.Texture2D icon, System.Boolean selectable)

Summary

Adds an item with optional text and icon.

Remarks

The item is enabled by default. Use Electron2D.ItemList.SetItemDisabled(System.Int32,System.Boolean) to prevent user input from selecting it.

Parameters

  • text: The text displayed by the item.
  • icon: The optional icon texture.
  • selectable: Whether the item can be selected.

Returns

The zero-based index of the created item.

Exceptions

  • System.ArgumentNullException: Thrown when text is null.

Thread Safety

This method is not synchronized. Call it on the main scene thread.

Since

This method is available since Electron2D 0.1.0 Preview.

See Also

  • Electron2D.ItemList.AddIconItem(Electron2D.Texture2D,System.Boolean)

Clear()

Kind: Method

public System.Void Clear()()

Summary

Removes every item and clears selection.

Remarks

The registered signals remain available after clearing.

Thread Safety

This method is not synchronized. Call it on the main scene thread.

Since

This method is available since Electron2D 0.1.0 Preview.

See Also

  • Electron2D.ItemList.AddItem(System.String,Electron2D.Texture2D,System.Boolean)

Deselect(System.Int32)

Kind: Method

public System.Void Deselect(System.Int32)(System.Int32 idx)

Summary

Clears selection from one item.

Remarks

Calling this method for an unselected item is a no-op.

Parameters

  • idx: The item index.

Exceptions

  • System.ArgumentOutOfRangeException: Thrown when idx is outside the item list.

Thread Safety

This method is not synchronized. Call it on the main scene thread.

Since

This method is available since Electron2D 0.1.0 Preview.

See Also

  • Electron2D.ItemList.Select(System.Int32,System.Boolean)

DeselectAll()

Kind: Method

public System.Void DeselectAll()()

Summary

Clears selection from every item.

Remarks

Multi-selection deselect signals are emitted for items that were selected.

Thread Safety

This method is not synchronized. Call it on the main scene thread.

Since

This method is available since Electron2D 0.1.0 Preview.

See Also

  • Electron2D.ItemList.GetSelectedItems

GetItemAtPosition(Electron2D.Vector2, System.Boolean)

Kind: Method

public System.Int32 GetItemAtPosition(Electron2D.Vector2, System.Boolean)(Electron2D.Vector2 position, System.Boolean exact)

Summary

Gets the item index at a local position.

Remarks

The preview list uses one row per item. Column wrapping is stored but not used for hit-testing yet.

Parameters

  • position: The local list position.
  • exact: Whether positions outside the horizontal bounds should return -1.

Returns

The item index at the position, or -1 when no item is present.

Thread Safety

This method is not synchronized. Call it on the main scene thread.

Since

This method is available since Electron2D 0.1.0 Preview.

See Also

  • Electron2D.ItemList._GuiInput(Electron2D.InputEvent)

GetItemCount()

Kind: Method

public System.Int32 GetItemCount()()

Summary

Gets the number of stored items.

Remarks

This method mirrors the method-based API shape used by other list operations.

Returns

The same value as Electron2D.ItemList.ItemCount.

Thread Safety

This method is not synchronized. Call it on the main scene thread.

Since

This method is available since Electron2D 0.1.0 Preview.

See Also

  • Electron2D.ItemList.ItemCount

GetItemIcon(System.Int32)

Kind: Method

public Electron2D.Texture2D GetItemIcon(System.Int32)(System.Int32 idx)

Summary

Gets the icon displayed by an item.

Remarks

Use Electron2D.ItemList.SetItemIcon(System.Int32,Electron2D.Texture2D) to replace or clear the icon.

Parameters

  • idx: The item index.

Returns

The item icon, or null when the item has no icon.

Exceptions

  • System.ArgumentOutOfRangeException: Thrown when idx is outside the item list.

Thread Safety

This method is not synchronized. Call it on the main scene thread.

Since

This method is available since Electron2D 0.1.0 Preview.

See Also

  • Electron2D.ItemList.SetItemIcon(System.Int32,Electron2D.Texture2D)

GetItemText(System.Int32)

Kind: Method

public System.String GetItemText(System.Int32)(System.Int32 idx)

Summary

Gets the text displayed by an item.

Remarks

The returned string is never null.

Parameters

  • idx: The item index.

Returns

The item text.

Exceptions

  • System.ArgumentOutOfRangeException: Thrown when idx is outside the item list.

Thread Safety

This method is not synchronized. Call it on the main scene thread.

Since

This method is available since Electron2D 0.1.0 Preview.

See Also

  • Electron2D.ItemList.SetItemText(System.Int32,System.String)

GetSelectedItems()

Kind: Method

public System.Int32[] GetSelectedItems()()

Summary

Gets the indices of selected items.

Remarks

The returned array is detached from the list and can be mutated by the caller.

Returns

A new array containing selected item indices in ascending order.

Thread Safety

This method is not synchronized. Call it on the main scene thread.

Since

This method is available since Electron2D 0.1.0 Preview.

See Also

  • Electron2D.ItemList.IsSelected(System.Int32)

IsItemDisabled(System.Int32)

Kind: Method

public System.Boolean IsItemDisabled(System.Int32)(System.Int32 idx)

Summary

Reports whether an item is disabled.

Remarks

Disabled items cannot be selected by user input.

Parameters

  • idx: The item index.

Returns

true when the item is disabled; otherwise, false.

Exceptions

  • System.ArgumentOutOfRangeException: Thrown when idx is outside the item list.

Thread Safety

This method is not synchronized. Call it on the main scene thread.

Since

This method is available since Electron2D 0.1.0 Preview.

See Also

  • Electron2D.ItemList.SetItemDisabled(System.Int32,System.Boolean)

IsItemSelectable(System.Int32)

Kind: Method

public System.Boolean IsItemSelectable(System.Int32)(System.Int32 idx)

Summary

Reports whether an item can be selected.

Remarks

Disabled items are not selected even when this flag is true.

Parameters

  • idx: The item index.

Returns

true when the item is selectable; otherwise, false.

Exceptions

  • System.ArgumentOutOfRangeException: Thrown when idx is outside the item list.

Thread Safety

This method is not synchronized. Call it on the main scene thread.

Since

This method is available since Electron2D 0.1.0 Preview.

See Also

  • Electron2D.ItemList.SetItemSelectable(System.Int32,System.Boolean)

IsSelected(System.Int32)

Kind: Method

public System.Boolean IsSelected(System.Int32)(System.Int32 idx)

Summary

Reports whether an item is selected.

Remarks

Selection state can be changed by user input or by Electron2D.ItemList.Select(System.Int32,System.Boolean).

Parameters

  • idx: The item index.

Returns

true when the item is selected; otherwise, false.

Exceptions

  • System.ArgumentOutOfRangeException: Thrown when idx is outside the item list.

Thread Safety

This method is not synchronized. Call it on the main scene thread.

Since

This method is available since Electron2D 0.1.0 Preview.

See Also

  • Electron2D.ItemList.GetSelectedItems

Select(System.Int32, System.Boolean)

Kind: Method

public System.Void Select(System.Int32, System.Boolean)(System.Int32 idx, System.Boolean single)

Summary

Selects an item.

Remarks

Disabled or non-selectable items are ignored. The method emits item_selected and, in multi selection mode, multi_selected when selection changes or Electron2D.ItemList.AllowReselect is enabled.

Parameters

  • idx: The item index.
  • single: Whether other selected items should be cleared.

Exceptions

  • System.ArgumentOutOfRangeException: Thrown when idx is outside the item list.

Thread Safety

This method is not synchronized. Call it on the main scene thread.

Since

This method is available since Electron2D 0.1.0 Preview.

See Also

  • Electron2D.ItemList.Deselect(System.Int32)

SetItemDisabled(System.Int32, System.Boolean)

Kind: Method

public System.Void SetItemDisabled(System.Int32, System.Boolean)(System.Int32 idx, System.Boolean disabled)

Summary

Sets whether an item ignores user selection and activation.

Remarks

Disabling a selected item clears its selected state.

Parameters

  • idx: The item index.
  • disabled: true to disable the item; otherwise, false.

Exceptions

  • System.ArgumentOutOfRangeException: Thrown when idx is outside the item list.

Thread Safety

This method is not synchronized. Call it on the main scene thread.

Since

This method is available since Electron2D 0.1.0 Preview.

See Also

  • Electron2D.ItemList.IsItemDisabled(System.Int32)

SetItemIcon(System.Int32, Electron2D.Texture2D)

Kind: Method

public System.Void SetItemIcon(System.Int32, Electron2D.Texture2D)(System.Int32 idx, Electron2D.Texture2D icon)

Summary

Sets the icon displayed by an item.

Remarks

Icons are optional and do not affect selection state.

Parameters

  • idx: The item index.
  • icon: The icon texture, or null to remove it.

Exceptions

  • System.ArgumentOutOfRangeException: Thrown when idx is outside the item list.

Thread Safety

This method is not synchronized. Call it on the main scene thread.

Since

This method is available since Electron2D 0.1.0 Preview.

See Also

  • Electron2D.ItemList.GetItemIcon(System.Int32)

SetItemSelectable(System.Int32, System.Boolean)

Kind: Method

public System.Void SetItemSelectable(System.Int32, System.Boolean)(System.Int32 idx, System.Boolean selectable)

Summary

Sets whether an item can be selected.

Remarks

Making an item non-selectable clears its selected state.

Parameters

  • idx: The item index.
  • selectable: true to allow selection; otherwise, false.

Exceptions

  • System.ArgumentOutOfRangeException: Thrown when idx is outside the item list.

Thread Safety

This method is not synchronized. Call it on the main scene thread.

Since

This method is available since Electron2D 0.1.0 Preview.

See Also

  • Electron2D.ItemList.IsItemSelectable(System.Int32)

SetItemText(System.Int32, System.String)

Kind: Method

public System.Void SetItemText(System.Int32, System.String)(System.Int32 idx, System.String text)

Summary

Sets the text displayed by an item.

Remarks

Assigning text queues a redraw. Empty text is valid.

Parameters

  • idx: The item index.
  • text: The new item text.

Exceptions

  • System.ArgumentOutOfRangeException: Thrown when idx is outside the item list.
  • System.ArgumentNullException: Thrown when text is null.

Thread Safety

This method is not synchronized. Call it on the main scene thread.

Since

This method is available since Electron2D 0.1.0 Preview.

See Also

  • Electron2D.ItemList.GetItemText(System.Int32)

_Draw()

Kind: Method

public System.Void _Draw()()

Summary

Draws the list rows, selection backgrounds and text.

Remarks

Text drawing is skipped when no theme font is available.

Thread Safety

This callback is invoked on the main scene thread.

Since

This method is available since Electron2D 0.1.0 Preview.

See Also

  • Electron2D.CanvasItem.DrawRect(Electron2D.Rect2,Electron2D.Color,System.Boolean,System.Single,System.Boolean)

_GetMinimumSize()

Kind: Method

public Electron2D.Vector2 _GetMinimumSize()()

Summary

Gets the minimum size requested by this list.

Remarks

The minimum width uses Electron2D.ItemList.FixedColumnWidth when it is positive; otherwise it uses a conservative fallback.

Returns

A size large enough to show the stored rows at the current row height.

Thread Safety

This callback is invoked on the main scene thread.

Since

This method is available since Electron2D 0.1.0 Preview.

See Also

  • Electron2D.Control.GetMinimumSize

_GuiInput(Electron2D.InputEvent)

Kind: Method

public System.Void _GuiInput(Electron2D.InputEvent)(Electron2D.InputEvent inputEvent)

Summary

Handles GUI input routed to this list.

Remarks

Mouse and touch press select rows. Double-click and activation keys emit item_activated for the selected item.

Parameters

  • inputEvent: The input event delivered by the viewport.

Thread Safety

This callback is invoked on the main scene thread.

Since

This method is available since Electron2D 0.1.0 Preview.

See Also

  • Electron2D.Control._GuiInput(Electron2D.InputEvent)

Clone this wiki locally