Skip to content

PickerWidget

Namespace: Hex1b.Widgets

Assembly: Hex1b.dll

A dropdown picker widget that shows a selected value and opens a list popup when activated. Selection state is owned by the node and preserved across reconciliation.

csharp
public sealed record PickerWidget : Hex1bWidget, IEquatable<Hex1bWidget>, IEquatable<PickerWidget>

Inheritance

ObjectHex1bWidgetPickerWidget

Implements

Constructors

PickerWidget(IReadOnlyList<string>)

A dropdown picker widget that shows a selected value and opens a list popup when activated. Selection state is owned by the node and preserved across reconciliation.

Parameters:

csharp
public PickerWidget(IReadOnlyList<string> Items)

Properties

InitialSelectedIndex

The initial selected index when the picker is first created. Defaults to 0 (first item).

Returns: Int32

csharp
public int InitialSelectedIndex { get; init; }

Items

The list of items to choose from.

Returns: IReadOnlyList<String>

csharp
public IReadOnlyList<string> Items { get; init; }

Methods

OnSelectionChanged(Action<PickerSelectionChangedEventArgs>)

Sets a synchronous handler called when the selection changes.

Parameters:

Returns: PickerWidget

csharp
public PickerWidget OnSelectionChanged(Action<PickerSelectionChangedEventArgs> handler)

OnSelectionChanged(Func<PickerSelectionChangedEventArgs, Task>)

Sets an asynchronous handler called when the selection changes.

Parameters:

Returns: PickerWidget

csharp
public PickerWidget OnSelectionChanged(Func<PickerSelectionChangedEventArgs, Task> handler)

Remarks

Picker is a composite widget that renders as a button showing the current selection. When clicked (or activated via keyboard), it opens an anchored popup containing a list of all available items. Selecting an item updates the picker and closes the popup.

The selection state () is owned by the node, not the widget. This means the picker maintains its selection across re-renders. Use the OnSelectionChanged method to react to selection changes.

Examples

csharp
ctx.Picker(["Apple", "Banana", "Cherry"])
    .OnSelectionChanged(e => Console.WriteLine($"Selected: {e.SelectedText}"));

Released under the MIT License.