TextViewKeyboard Class
Definition
Handles keyboard navigation and read-only commands (copy, select-all) for text views.
public class TextViewKeyboard
Remarks
This component works with Avalonia.Controls.Documents.TextModel.TextDocument and Avalonia.Controls.TextSelection, using their TextPointer support for all operations. The caret operations a subclass would need are internal, so the type is closed: the constructor is internal and only this library derives from it. Add behaviour to a view with an Avalonia.Controls.Documents.Primitives.Components.ITextViewComponent of your own, or a highlight layer.
Constructors
| Name | Description |
|---|---|
| TextViewKeyboard | Creates the component. A view builds its own, so a consumer rarely needs to. |
TextViewKeyboard Constructor
Creates the component. A view builds its own, so a consumer rarely needs to.
public TextViewKeyboard()
Remarks
Deriving from this type is not supported: the seams a subclass would need are internal to the view. The constructor is public for compatibility with the released surface, not as an invitation.
Methods
| Name | Description |
|---|---|
| Copy | Copies the current selection to the clipboard without waiting for the clipboard write. |
| CopyAsync | Copies the current selection to the clipboard. |
Copy Method
Copies the current selection to the clipboard without waiting for the clipboard write.
public void Copy()
Remarks
Await Avalonia.Controls.Documents.Primitives.Components.TextViewKeyboard.CopyAsync(System.Threading.CancellationToken) instead. The clipboard is a platform resource another process can hold, so the write can fail after this method has already returned, and a caller here can neither see that nor sequence anything after it.
CopyAsync Method
Copies the current selection to the clipboard.
public System.Threading.Tasks.Task CopyAsync(System.Threading.CancellationToken cancellationToken)
Parameters
cancellationToken System.Threading.CancellationToken
Abandons the copy before the clipboard is written.
Returns
System.Threading.Tasks.Task
Remarks
Base behaviour publishes plain text only. The editor overrides this to also publish the rich-format (RTF) payload.
Properties
| Name | Description |
|---|---|
| IsAttached | Gets whether this component is currently attached to a host. Inherited from TextViewComponentBase. |