Class SelectionState
- Namespace
- MiniTui
- Assembly
- MiniTui.dll
The selected row and scroll offset of a list or table (§8.2). The widget clamps Selected and adjusts Offset while drawing, so the selection is always visible.
public sealed class SelectionState
- Inheritance
-
SelectionState
- Inherited Members
Properties
Offset
The first visible index. Adjusted when drawn so Selected is visible after the selection moves; the wheel and the scrollbar scroll without moving the selection (1.x spec §14.4).
public int Offset { get; set; }
Property Value
Selected
The selected index. Clamped to the item count when drawn. Setting it (or moving it with a key) scrolls it into view at the next draw.
public int Selected { get; set; }
Property Value
SortColumn
The column the data is sorted by, for the ▲/▼ header marker. Display only.
public int? SortColumn { get; set; }
Property Value
- int?
SortDescending
Whether SortColumn is sorted descending (▼). Display only.
public bool SortDescending { get; set; }
Property Value
ViewportHeight
How many rows were visible at the last draw. Used by PageDown(int) and PageUp(int).
public int ViewportHeight { get; }
Property Value
Methods
First()
Select the first item.
public void First()
HandleKey(ConsoleKeyInfo, int)
Handle ↑ ↓ j k PgUp PgDn Home End.
public bool HandleKey(ConsoleKeyInfo key, int count)
Parameters
keyConsoleKeyInfocountint
Returns
- bool
True if the key was a navigation key.
HandleMouse(MouseEvent, int)
Handle the mouse over the list or table drawn last (1.x spec §4.8, §14.4, §14.5): the wheel scrolls by one item, a left press on a visible row selects it, the scrollbar's thumb drags and its track pages, and a press on a sortable header cell calls ToggleSort(int). Scrolling doesn't move the selection. A double-click on a row raises Activated.
public bool HandleMouse(MouseEvent mouse, int count)
Parameters
mouseMouseEventcountint
Returns
- bool
True if the event did any of these.
Last(int)
Select the last item.
public void Last(int count)
Parameters
countint
Next(int)
Select the next item, stopping at the last.
public void Next(int count)
Parameters
countint
PageDown(int)
Move the selection down by one viewport.
public void PageDown(int count)
Parameters
countint
PageUp(int)
Move the selection up by one viewport.
public void PageUp(int count)
Parameters
countint
Previous(int)
Select the previous item, stopping at the first.
public void Previous(int count)
Parameters
countint
ToggleSort(int)
The column the data is sorted by, ascending if it wasn't already, else the other way (1.x spec §14.5). Raises SortChanged.
public void ToggleSort(int column)
Parameters
columnint
Events
Activated
Raised on the UI thread when a row is double-clicked (1.x spec §17.4), after the first press selected it, so the row is Selected.
public event EventHandler? Activated
Event Type
SortChanged
Raised on the UI thread when a header click or ToggleSort(int) sorts by a column, for the app to sort its items.
public event EventHandler? SortChanged