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.IUndoManager.Redo directly. The default implementation forwards to the document's undo manager without restoring caret state; editor controls should override to add restoration.
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.IUndoManager.Undo directly — direct calls skip caret restoration. The default implementation forwards to the document's undo manager without restoring caret state; editor controls should override to add restoration.
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; }
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. The default implementation is a no-op, which is acceptable for hosts that never toggle Avalonia.Controls.Documents.Primitives.ITextEditorHost.IsReadOnly.