Skip to content

ListWidget<T>

Namespace: Hex1b.Widgets

Assembly: Hex1b.dll

Widget for displaying a selectable list of typed items. Selection state is owned by the node and preserved across reconciliation. Supports per-row custom rendering via ItemTemplate — see .

csharp
public record ListWidget<T> : Hex1bWidget, IEquatable<Hex1bWidget>, IEquatable<ListWidget<T>>

Inheritance

ObjectHex1bWidgetListWidget<T>

Implements

Constructors

ListWidget(IReadOnlyList<T>?)

Widget for displaying a selectable list of typed items. Selection state is owned by the node and preserved across reconciliation. Supports per-row custom rendering via ItemTemplate — see .

Parameters:

csharp
public ListWidget(IReadOnlyList<T>? Items)

Properties

ControlledFocusedIndex

When set, drives the focused index on every reconciliation rather than only at creation time. Use this to build "controlled" lists whose cursor lives in an owning composite's state (e.g. a search-filtered selection prompt where the textbox forwards Up/Down to the list). Out-of-range values are clamped to the current item range.

Returns: Nullable<Int32>

csharp
public int? ControlledFocusedIndex { get; init; }

InitialFocusedIndex

The initial focused index when the list is first created. Defaults to 0. Only applied when the node is new.

Returns: Int32

csharp
public int InitialFocusedIndex { get; init; }

InitialSelectedIndex

Legacy alias for . Kept source-compatible with pre-multi-select code that used InitialSelectedIndex; both names target the same backing field.

Returns: Int32

csharp
[Obsolete("Use InitialFocusedIndex instead. This alias exists for source compatibility and will be removed in a future release.")]
public int InitialSelectedIndex { get; init; }

InitialSelectedIndices

The initial checked set when the list is first created. Defaults to empty. Only applied when the node is new and when multi-select is enabled. Use instead for a controlled (re-applied every frame) checked set.

Returns: IReadOnlyList<Int32>

csharp
public IReadOnlyList<int>? InitialSelectedIndices { get; init; }

IsMultiSelectEnabled

When true, the list supports multi-select: Space toggles the focused row's checked state, Shift+Arrows extend a range, Ctrl+A selects (or deselects) all, and rendered rows expose the checked state through . When the default row renderer is in use, a checkbox glyph is drawn in front of each row. Set via widget.MultiSelect().

Returns: Boolean

csharp
public bool IsMultiSelectEnabled { get; init; }

ItemHeight

The fixed row height in terminal rows for each item. Defaults to 1. Templates with content shorter than this are padded; taller content is clipped.

Returns: Int32

csharp
public int ItemHeight { get; init; }

Items

Returns: IReadOnlyList<<T>>

csharp
public IReadOnlyList<T>? Items { get; init; }

SelectedIndices

When set, drives the checked set on every reconciliation rather than only at creation time — the controlled-state form of multi-select. Indices outside the current item range are silently dropped. Mutually exclusive with ; if both are set, this wins.

Returns: IReadOnlyList<Int32>

csharp
public IReadOnlyList<int>? SelectedIndices { get; init; }

Methods

Empty(Func<RootContext, Hex1bWidget>)

Configures an empty-state widget rendered when the list has no items. Mirrors TableWidget&lt;TRow&gt;.Empty(...) — pass a builder that returns the widget tree to render in place of the list contents.

Parameters:

Returns: ListWidget`1

csharp
public ListWidget<T> Empty(Func<RootContext, Hex1bWidget> builder)

Fields

Activate

Rebindable action: Activate the selected item.

Returns: ActionId

csharp
public static readonly ActionId Activate

ExtendSelectionDown

Rebindable action: Extend the selection one row down from the anchor. Default binding: Shift+DownArrow. Only bound when multi-select is enabled.

Returns: ActionId

csharp
public static readonly ActionId ExtendSelectionDown

ExtendSelectionToFirst

Rebindable action: Extend the selection to the first row. Default binding: Shift+Home. Only bound when multi-select is enabled.

Returns: ActionId

csharp
public static readonly ActionId ExtendSelectionToFirst

ExtendSelectionToLast

Rebindable action: Extend the selection to the last row. Default binding: Shift+End. Only bound when multi-select is enabled.

Returns: ActionId

csharp
public static readonly ActionId ExtendSelectionToLast

ExtendSelectionUp

Rebindable action: Extend the selection one row up from the anchor. Default binding: Shift+UpArrow. Only bound when multi-select is enabled.

Returns: ActionId

csharp
public static readonly ActionId ExtendSelectionUp

MoveDown

Rebindable action: Move selection down.

Returns: ActionId

csharp
public static readonly ActionId MoveDown

MoveToFirst

Rebindable action: Move selection to the first item.

Returns: ActionId

csharp
public static readonly ActionId MoveToFirst

MoveToLast

Rebindable action: Move selection to the last item.

Returns: ActionId

csharp
public static readonly ActionId MoveToLast

MoveUp

Rebindable action: Move selection up.

Returns: ActionId

csharp
public static readonly ActionId MoveUp

PageDown

Rebindable action: Move selection down by one viewport.

Returns: ActionId

csharp
public static readonly ActionId PageDown

PageUp

Rebindable action: Move selection up by one viewport.

Returns: ActionId

csharp
public static readonly ActionId PageUp

ScrollDown

Rebindable action: Scroll down.

Returns: ActionId

csharp
public static readonly ActionId ScrollDown

ScrollUp

Rebindable action: Scroll up.

Returns: ActionId

csharp
public static readonly ActionId ScrollUp

SelectAll

Rebindable action: Select all rows (or deselect all when every row is already selected). Default binding: Ctrl+A. Only bound when multi-select is enabled.

Returns: ActionId

csharp
public static readonly ActionId SelectAll

ToggleSelection

Rebindable action: Toggle the focused row's checked state. Default binding: Space. Only bound when multi-select is enabled.

Returns: ActionId

csharp
public static readonly ActionId ToggleSelection

Released under the MIT License.