Skip to main content

TextModal class

Namespace: Arlecchino.Modals.Asking · Assembly: Arlecchino

A line of text: free text, a secret, an email or a link. The built-in format check runs before TextModal.Validate, so your validator only sees input that already looks right.

public sealed class TextModal : Modal, ITextEntryModal, IAffixedModal, ITextEntry

Inherits from Modal
Implements ITextEntryModal, IAffixedModal, ITextEntry

Constructors

MemberSummary
TextModal()

Properties

MemberSummary
AnchorWhere the selection was started from, on the caret while nothing is selected.
CaretWhere the caret sits, pulled into the text when it would fall outside.
FormatBuilt-in check applied on confirm.
MaskedWhether to draw dots instead of the text.
MessageValidation message shown under the field.
OnSubmitCalled with the accepted text.
PrefixDrawn before the field.
SuffixDrawn after the field.
TextWhatever has been typed so far. Assigning it puts the caret at the end.
TypingThe line being typed into, which for a field of one line is the field itself.
ValidateYour own check, run after the format one. Return a message to keep the dialog open.

Methods

MemberSummary
AcceptsCharacter(char)Accepts anything that can be typed.
Draw(ModalFrame)
Handle(ModalFrame, KeyPress)

Constructors in detail

TextModal()

Obsolete

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

public TextModal();

Properties in detail

Anchor

public int Anchor { get; set; }

Where the selection was started from, on the caret while nothing is selected.

Type int

Caret

public int Caret { get; set; }

Where the caret sits, pulled into the text when it would fall outside.

Type int

Format

public TextFormat Format { get; init; }

Built-in check applied on confirm.

Type TextFormat

Masked

public bool Masked { get; init; }

Whether to draw dots instead of the text.

Type bool

Message

public string? Message { get; set; }

Validation message shown under the field.

Type string

OnSubmit

public Action<string> OnSubmit { get; init; }

Called with the accepted text.

Type Action<T><string>

Prefix

public string Prefix { get; init; }

Drawn before the field.

Type string

Suffix

public string Suffix { get; init; }

Drawn after the field.

Type string

Text

public string Text { get; set; }

Whatever has been typed so far. Assigning it puts the caret at the end.

Type string

Typing

public override ITextEntry Typing { get; }

The line being typed into, which for a field of one line is the field itself.

Type ITextEntry

Validate

public Func<string, string?>? Validate { get; init; }

Your own check, run after the format one. Return a message to keep the dialog open.

Type Func<T, TResult><string, string>

Methods in detail

AcceptsCharacter(char)

public bool AcceptsCharacter(char character);

Accepts anything that can be typed.

Parameters

NameTypeDescription
charactercharThe character resolved from the key press.

Returns bool — Always true.

Draw(ModalFrame)

public override void Draw(ModalFrame frame);

Parameters

NameTypeDescription
frameModalFrame

Handle(ModalFrame, KeyPress)

public override void Handle(ModalFrame frame, KeyPress key);

Parameters

NameTypeDescription
frameModalFrame
keyKeyPress