Skip to main content

OptionListModal class

Namespace: Arlecchino.Modals.Choosing · Assembly: Arlecchino

What the single- and multi-choice dialogs share: the options, what has been typed to narrow them, and the cursor. What is typed is edited the way any other line is, so a symbol goes in one press.

public abstract class OptionListModal : Modal, ITextEntry

Inherits from Modal
Implements ITextEntry
Derived types ChoiceModal, MultiChoiceModal

Constructors

MemberSummary
OptionListModal()

Properties

MemberSummary
AnchorWhere a selection would start from, on the caret since none is drawn here.
CaretWhere the caret sits in what has been typed, which is at the end of it.
FirstVisibleIndex of the first option drawn, since a long list only shows a window of it.
IndexCursor position within the options that match.
OptionsEverything that can be chosen from.
RowsWhere the rows were drawn last frame, used to turn a click into a row.
TextWhatever has been typed to narrow the list. Editing it resets the cursor to the top.
TypingThe line being typed into, which here is what narrows the list.

Methods

MemberSummary
HandleMouse(ModalFrame, MouseEvent)The wheel walks the list, and a click picks the row it landed on. A row is taken only when it was already the one under the cursor.
HandlePaste(ModalFrame, string)Takes pasted text into the filter and puts the cursor back on the first row, since what is showing after the paste is a different set of rows.
MatchingOptions()The options that pass the filter, in their original order.
Take(ModalFrame, string)Acts on the row that was picked, which is what tells one kind of list from the other.

Constructors in detail

OptionListModal()

Obsolete

Constructors of types with required members are not supported in this version of your compiler.

public OptionListModal();

Properties in detail

Anchor

public int Anchor { get; set; }

Where a selection would start from, on the caret since none is drawn here.

Type int

Caret

public int Caret { get; set; }

Where the caret sits in what has been typed, which is at the end of it.

Type int

FirstVisible

public int FirstVisible { get; set; }

Index of the first option drawn, since a long list only shows a window of it.

Type int

Index

public int Index { get; set; }

Cursor position within the options that match.

Type int

Options

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

Everything that can be chosen from.

Type IReadOnlyList<T><string>

Rows

public SurfaceRegion Rows { get; set; }

Where the rows were drawn last frame, used to turn a click into a row.

Type SurfaceRegion

Text

public string Text { get; set; }

Whatever has been typed to narrow the list. Editing it resets the cursor to the top.

Type string

Typing

public override ITextEntry Typing { get; }

The line being typed into, which here is what narrows the list.

Type ITextEntry

Methods in detail

HandleMouse(ModalFrame, MouseEvent)

public override void HandleMouse(ModalFrame frame, MouseEvent mouse);

The wheel walks the list, and a click picks the row it landed on. A row is taken only when it was already the one under the cursor.

Parameters

NameTypeDescription
frameModalFrameHow to close.
mouseMouseEventThe event that arrived.

HandlePaste(ModalFrame, string)

public override void HandlePaste(ModalFrame frame, string text);

Takes pasted text into the filter and puts the cursor back on the first row, since what is showing after the paste is a different set of rows.

Parameters

NameTypeDescription
frameModalFrameThe keys to obey, and how to close.
textstringWhat was pasted.

MatchingOptions()

public List<string> MatchingOptions();

The options that pass the filter, in their original order.

Returns List<T><string> — Matching options; all of them when nothing is typed.

Take(ModalFrame, string)

public abstract void Take(ModalFrame frame, string choice);

Acts on the row that was picked, which is what tells one kind of list from the other.

Parameters

NameTypeDescription
frameModalFrameHow to close, when picking closes.
choicestringThe option.