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
| Member | Summary |
|---|---|
TextModal() |
Properties
| Member | Summary |
|---|---|
Anchor | Where the selection was started from, on the caret while nothing is selected. |
Caret | Where the caret sits, pulled into the text when it would fall outside. |
Format | Built-in check applied on confirm. |
Masked | Whether to draw dots instead of the text. |
Message | Validation message shown under the field. |
OnSubmit | Called with the accepted text. |
Prefix | Drawn before the field. |
Suffix | Drawn after the field. |
Text | Whatever has been typed so far. Assigning it puts the caret at the end. |
Typing | The line being typed into, which for a field of one line is the field itself. |
Validate | Your own check, run after the format one. Return a message to keep the dialog open. |
Methods
| Member | Summary |
|---|---|
AcceptsCharacter(char) | Accepts anything that can be typed. |
Draw(ModalFrame) | |
Handle(ModalFrame, KeyPress) |
Constructors in detail
TextModal()
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
| Name | Type | Description |
|---|---|---|
character | char | The character resolved from the key press. |
Returns bool — Always true.
Draw(ModalFrame)
public override void Draw(ModalFrame frame);
Parameters
| Name | Type | Description |
|---|---|---|
frame | ModalFrame |
Handle(ModalFrame, KeyPress)
public override void Handle(ModalFrame frame, KeyPress key);
Parameters
| Name | Type | Description |
|---|---|---|
frame | ModalFrame | |
key | KeyPress |