Table of Contents

Class SelectState

Namespace
MiniTui
Assembly
MiniTui.dll

The options and choice of a dropdown field (1.x spec §7.5), drawn with Select(). Opening it shows a PopupMenu of the options below the field.

public sealed class SelectState
Inheritance
SelectState
Inherited Members

Constructors

SelectState(IReadOnlyList<string>?, int?)

Create a state with options and an optional choice.

public SelectState(IReadOnlyList<string>? options = null, int? selected = null)

Parameters

options IReadOnlyList<string>
selected int?

Properties

Filterable

Open a dropdown with a filter line instead of a plain menu, so typing narrows the options, and let a character typed on the closed field open it with that character in the filter (1.x spec §13.6). Default false.

public bool Filterable { get; set; }

Property Value

bool

IsOpen

True while its menu is open.

public bool IsOpen { get; }

Property Value

bool

Options

The options. Setting them keeps Selected if it's still in range, otherwise clears it.

public IReadOnlyList<string> Options { get; set; }

Property Value

IReadOnlyList<string>

Selected

The chosen option's index, or null for none (the placeholder shows). Clamped to the options when set.

public int? Selected { get; set; }

Property Value

int?

Value

The chosen option, or null.

public string? Value { get; }

Property Value

string

Methods

HandleKey(ConsoleKeyInfo, App)

Enter, Space, ↑, ↓, Alt+↓ and F4 open the menu; with Filterable, so does a typed character, which starts the filter. Returns true if it opened.

public bool HandleKey(ConsoleKeyInfo key, App app)

Parameters

key ConsoleKeyInfo
app App

Returns

bool

HandleMouse(MouseEvent, App)

A left press on the field from the last draw opens the menu. Returns true if it opened.

public bool HandleMouse(MouseEvent mouse, App app)

Parameters

mouse MouseEvent
app App

Returns

bool

Open(App)

Show the options in a PopupMenu below the field from the last draw, as wide as it, with the current choice selected; with Filterable, a dropdown with a filter line. Does nothing while open or with no options.

public void Open(App app)

Parameters

app App

Events

Changed

Raised on the UI thread when the user's choice changes Selected (not when code sets it).

public event EventHandler? Changed

Event Type

EventHandler