-
Notifications
You must be signed in to change notification settings - Fork 0
DocumentController
Dustin Horne edited this page Mar 5, 2026
·
1 revision
Namespace: ParentElement.RichText.Core.Controllers
The concrete implementation of IDocumentController. Create one instance per editor surface and connect it to your UI by wiring up the RequestRedraw and RequestCursorUpdate callbacks and forwarding pointer and keyboard events.
public class DocumentController : IDocumentControllerpublic DocumentController(DocumentSettings settings, IClipboardHandler clipboard)| Parameter | Type | Description |
|---|---|---|
settings |
DocumentSettings |
Initial page configuration — size, margins, default style |
clipboard |
IClipboardHandler |
Platform clipboard adapter used by copy, cut, and paste |
var settings = new DocumentSettings
{
PageWidth = 816, // US Letter at 96 dpi
ShowPageBreaks = true,
DocumentMargins = new DocumentMargins(72, 72, 72, 72),
};
IDocumentController editor = new DocumentController(settings, new MyClipboard());
editor.RequestRedraw = () => surface.InvalidateSurface();
editor.RequestCursorUpdate = cursor => UpdatePlatformCursor(cursor);All members are documented on the IDocumentController page. The sections below note any implementation-specific behaviour.
| Property | Default | Notes |
|---|---|---|
SelectionColor |
SKColors.LightGray |
Updated at any time; triggers redraw |
BackgroundColor |
SKColors.White |
Overrides DocumentSettings.DocumentBackgroundColor
|
VisibleBounds |
Rectangle(0,0,0,0) |
Must be set before the first Draw call |
ReadOnly |
false |
When true, key and pointer events that modify content are ignored |
HasFocus |
false |
Drives caret blinking; set true when the surface gains focus |
ScrollScale |
1.0 |
Set to the viewport zoom factor when translating pointer coordinates |
-
Undo/Redo is handled entirely by the underlying
TextDocument. -
Shortcut handling is evaluated inside
OnKeyEventbefore default key processing. - Table cell focus is managed automatically as the user clicks or types into cells.
- PDF export uses SkiaSharp's built-in PDF canvas backend.
See also: IDocumentController · Data-Structures · Input-and-Shortcuts · Tables