public abstract class TextFieldAnything the user types into.
No guide page documents this yet — the page shows what the code says about itself.
Remarks
One editing core under every field in the set. A text box, a search box, a numeric input and a combo box's editable half are one caret, one selection and one keyboard map wearing four skins; writing the map four times is how a control library ends up with a field where Ctrl-Left works and one where it does not.
⚠ Single line unless AcceptsNewlines says otherwise, which only TextArea does. A one-line field's value scrolls sideways rather than wrapping; a text area wraps, takes a newline from Enter, and moves its caret between lines. Both are the same caret, the same selection and the same keyboard map — the difference is three predicates rather than a second control.
⚠ A text area does not scroll vertically yet. Its lines are drawn where they fall and a value taller than the box is clipped by it, which is honest and is not enough: the box is sized by the theme (textarea { min-height }) and a caller that expects to hold a long document should say how tall it wants to be. A scroll region round the text is owed.
The caret is an index into the value and the selection is a second one. Both are UTF-16 indices on grapheme boundaries, which is what ShapedText works in — so moving the caret over an emoji or a Devanagari syllable steps over the whole of it, and the arithmetic that decides is the conformance-tested code in the text assembly rather than a loop here that would get the interesting scripts wrong.
Fields and properties (36)
protected override string TagNameThe element name this type answers to when a caller does not choose one.
public string? Valuepublic string? Placeholderpublic bool ReadOnlypublic int MaxLengthpublic bool Requiredpublic Func<string?, string?>? ValidatorWhat decides whether the value is acceptable, for a caller that will not subclass.
public string? ValidationMessageWhy the value is not acceptable, or null when it is.
public bool IsValidWhether the value is acceptable.
public int CaretIndexWhere the caret is, as a UTF-16 index into Value.
public TimeSpan CaretBlinkHow long the caret spends on, and then off. Zero draws it solid.
public CaretAffinity CaretAffinityWhich of the two characters either side of CaretIndex the caret is on.
public int SelectionAnchorWhere the selection started, as a UTF-16 index. Equal to the caret when nothing is selected.
public int SelectionStartThe lower end of the selection.
public int SelectionEndThe upper end.
public bool HasSelectionWhether anything is selected.
public string SelectedTextThe selected text.
public string CompositionWhat an input method is composing at the caret, and has not committed.
public bool IsComposingWhether an input method has an uncommitted pre-edit in this field.
public int DisplayCaretWhere the caret is in the string the field is displaying.
protected UiElement TextPartThe element the value is drawn on.
protected override AccessibleRole NativeRoleThe role this kind of element has when nobody says otherwise.
protected override string? NativeAccessibleNameprotected override string? NativeAccessibleValueprotected override AccessibleStates NativeAccessibleStatepublic bool CanCopyWhether there is something to put on the clipboard, and somewhere to put it.
public bool CanPasteWhether there is text on the clipboard and this field would take it.
protected virtual bool AcceptsNewlinesWhether Enter puts a line break in the value rather than submitting it.
protected bool ShowsCaretWhether the caret is drawn: a field that cannot be typed into has none.
public Rectangle CaretAreapublic bool AcceptsTextInputpublic static readonly UiPropertyKey ValuePropertyIdentity for Value.
public static readonly UiPropertyKey PlaceholderPropertyIdentity for Placeholder.
public static readonly UiPropertyKey ReadOnlyPropertyIdentity for ReadOnly.
public static readonly UiPropertyKey MaxLengthPropertyIdentity for MaxLength.
public static readonly UiPropertyKey RequiredPropertyIdentity for Required.
Events (2)
Methods (23)
protected override void OnCreated()Builds whatever this element is made of, once, as it joins a document.
public void MoveCaret(int index, bool extend = false)Moves the caret, and either drops the selection or extends it.
public void MoveCaret(int index, CaretAffinity affinity, bool extend = false)Moves the caret to one side of an index, and either drops the selection or extends it.
public void SelectAll()Selects the whole value.
public void SelectWord(int index)Selects the word an index falls inside.
public void Replace(string insertion)Replaces the selection — or, with none, inserts at the caret.
public bool Undo()Takes back the last edit, if this field is under an undo manager.
public bool Redo()Puts back the last undone edit.
public bool Copy()Puts the selection on the clipboard.
public bool Cut()Puts the selection on the clipboard and deletes it.
public bool Paste()Replaces the selection with the clipboard's text.
protected virtual string? Coerce(string? value)What the field does with a value on its way in.
protected virtual string? Shown(string? value)What the field draws for a value on its way out.
protected virtual string? Validate(string? value)Whether a value is acceptable, and why not when it is not.
public void Revalidate()Asks Validate again and republishes the answer.
protected virtual void OnSubmit()Called when Enter is pressed, before Submitted is raised.
protected virtual void SelectAt(int index, int count)What a repeated tap selects.
protected override void OnDraw(DrawContext context)public void ClearValue()Unsets Value, so it takes its default or its ancestor's value again.
public void ClearPlaceholder()Unsets Placeholder, so it takes its default or its ancestor's value again.
public void ClearReadOnly()Unsets ReadOnly, so it takes its default or its ancestor's value again.
public void ClearMaxLength()Unsets MaxLength, so it takes its default or its ancestor's value again.
public void ClearRequired()Unsets Required, so it takes its default or its ancestor's value again.
Used by (130, showing 40)
- GalleryHelloUi
- AccessibilityTreeTestsVixen.Ui.Controls.Tests
- AccessibleNameLocalisationTestsVixen.Ui.Controls.Advanced.Tests
- BindReachTestsVixen.Ui.Controls.Tests
- CaretAffinityTestsVixen.Ui.Controls.Tests
- CaretBlinkTestsVixen.Ui.Controls.Tests
- CaretColourPixelTestsVixen.Ui.Controls.Tests
- ClipboardTestsVixen.Ui.Controls.Tests
- ColorPickerVixen.Ui.Controls.Advanced
- ColorPickerTestsVixen.Ui.Controls.Advanced.Tests
- ComboBoxVixen.Ui.Controls
- ComboEditorVixen.Ui.Controls
- CommandBindingTestsVixen.Ui.Controls.Tests
- ControlThemeVisualTestsVixen.Ui.Controls.Tests
- DataCellVixen.Ui.Controls.Advanced
- DataGridVixen.Ui.Controls.Advanced
- DataGridTestsVixen.Ui.Controls.Advanced.Tests
- DialogServiceVixen.Ui.Controls
- DialogTestsVixen.Ui.Controls.Tests
- DisabledStateTestsVixen.Ui.Controls.Tests
- DockingTestsVixen.Ui.Controls.Advanced.Tests
- EditingParityTestsVixen.Ui.Controls.Advanced.Tests
- ElementStateBitTestsVixen.Ui.Controls.Tests
- FieldProbeVixen.Ui.Controls.Tests
- FieldValidationTestsVixen.Ui.Controls.Tests
- MarkupTestsVixen.Ui.Controls.Tests
- NavigationInteractionTestsVixen.Ui.Controls.Tests
- NestedMemberTestsVixen.Ui.Controls.Advanced.Tests
- NodeCanvasVixen.Ui.Controls.Advanced
- NodePortEditorVixen.Ui.Controls.Advanced
- NumericInputVixen.Ui.Controls
- ProbeVixen.Ui.Desktop.Tests
- PropertyGridVixen.Ui.Controls.Advanced
- PropertyGridTestsVixen.Ui.Controls.Advanced.Tests
- RtlFieldMirroringTestsVixen.Ui.Controls.Tests
- ScrubTestsVixen.Ui.Controls.Tests
- SearchBoxVixen.Ui.Controls
- SearchableReachTestsVixen.Ui.Controls.Tests
- SearchableSheetVixen.Ui.Controls.Tests
- SecureTextBoxVixen.Ui.Controls