Clipboard
Clay backend implementation for system clipboard operations.
This class provides cross-platform clipboard text access with support for:
- Native SDL clipboard on desktop platforms
- Electron clipboard API when running in Electron
- Browser clipboard API as a fallback on web
- Internal text storage as a last resort
Platform-specific behavior:
- Desktop (SDL): Direct system clipboard access
- Electron: Uses Electron's clipboard module with retry logic
- Web Browser: Uses navigator.clipboard API with permission handling
- Fallback: Internal string storage when system access unavailable
The browser clipboard implementation requires user permission and automatically syncs when the window gains focus.
Instance Members
Gets the current clipboard text content.
Attempts to read from the system clipboard in this order:
- Electron clipboard (if available)
- SDL system clipboard (on desktop)
- Internal clipboard storage (fallback)
Returns | Description |
---|---|
String | The clipboard text content, or null if empty |
Sets the clipboard text content.
Writes to all available clipboard targets:
- Internal storage (always)
- Electron clipboard (if available, with retry)
- Browser clipboard (if permissions granted)
- SDL system clipboard (on desktop)
The Electron implementation includes a 100ms delayed retry to work around timing issues with clipboard access.
Name | Type | Description |
---|---|---|
text |
String | The text to copy to the clipboard |
Creates a new clipboard handler. Automatically detects and initializes the appropriate clipboard API based on the platform and available features.
Private Members
Internal clipboard text storage used as fallback