ITextEditorHost Interface
Definition
Host interface for text editor controls that support text mutation.
public interface ITextEditorHost
Remarks
Extends Avalonia.Controls.Documents.Primitives.IInteractiveTextHost with editing-specific members: read-only gating, return/tab acceptance. Components that perform text mutation (typing, delete, paste, undo) require this interface.
Read-only interactive views should implement Avalonia.Controls.Documents.Primitives.IInteractiveTextHost directly instead.
Methods
| Name | Description |
|---|---|
| Redo | Redoes the most recently undone editing operation and restores any caret/selection state captured with the undo unit. |
| Undo | Undoes the most recent editing operation and restores any caret/selection state captured with the undo unit. |
Redo Method
Redoes the most recently undone editing operation and restores any caret/selection state captured with the undo unit.
public void Redo()
Remarks
All callers should route through this method instead of calling Avalonia.Controls.Documents.Undo.UndoManager.Redo directly, for the same reason Avalonia.Controls.Documents.Primitives.ITextEditorHost.Undo gives.
Undo Method
Undoes the most recent editing operation and restores any caret/selection state captured with the undo unit.
public void Undo()
Remarks
All callers (keyboard shortcuts, editor actions, menu items) should route through this method instead of calling Avalonia.Controls.Documents.Undo.UndoManager.Undo directly - direct calls skip caret restoration, which is what an implementation that only forwards to the undo manager produces.
Properties
| Name | Description |
|---|---|
| AcceptsReturn | Gets whether the editor accepts the Return/Enter key. |
| AcceptsTab | Gets whether the editor accepts the Tab key. |
| IsReadOnly | Gets whether the editor is in read-only mode. |
| SelectionFlyout | Gets the selection mini-bar flyout shown when text is selected. |
| ShowSelectionFlyout | Gets whether the selection mini-bar flyout is enabled. |
AcceptsReturn Property
Gets whether the editor accepts the Return/Enter key.
public bool AcceptsReturn { get; set; }
Remarks
When true, pressing Enter inserts a line break or paragraph. When false, Enter may trigger a command or be ignored.
AcceptsTab Property
Gets whether the editor accepts the Tab key.
public bool AcceptsTab { get; set; }
Remarks
When true, pressing Tab inserts a tab character. When false, Tab moves focus to the next control.
IsReadOnly Property
Gets whether the editor is in read-only mode.
public bool IsReadOnly { get; set; }
Remarks
When true, editing operations are disabled but navigation and selection still work.
SelectionFlyout Property
Gets the selection mini-bar flyout shown when text is selected.
public Avalonia.Controls.Documents.Primitives.EditorSelectionFlyout SelectionFlyout { get; set; }
Remarks
The mini-bar is chrome a control chooses to show, not an editing capability, so a host that presents no flyout leaves this null.
ShowSelectionFlyout Property
Gets whether the selection mini-bar flyout is enabled.
public bool ShowSelectionFlyout { get; set; }
Events
| Name | Description |
|---|---|
| IsReadOnlyChanged | Occurs when the Avalonia.Controls.Documents.Primitives.ITextEditorHost.IsReadOnly state changes. |
IsReadOnlyChanged Event
Occurs when the Avalonia.Controls.Documents.Primitives.ITextEditorHost.IsReadOnly state changes.
public event EventHandler IsReadOnlyChanged
Remarks
Toolbar tools and editor actions subscribe to this event to refresh their enabled state when read-only mode is toggled at runtime. A host that never toggles Avalonia.Controls.Documents.Primitives.ITextEditorHost.IsReadOnly can declare the event and never raise it; what it must not do is accept a subscription and drop it, which leaves the whole toolbar permanently stale with nothing to diagnose.