Manages copied, cut and dragged data for paste operations.
The Clipboard class stores references to copied data so that applications can offer cut, copy, paste and drag-and-drop workflows. Clipboard entries are grouped by datatype and are exposed to consumers as readable files, allowing large items to be pasted without first loading their contents into application memory.
Multiple Clipboard objects can be created, but they share the same clipboard store for the current process and user session. Each datatype normally has one active group of items. Adding a new group for the same datatype replaces the previous group unless the CEF::EXTEND flag is used.
On Windows, text and file references are integrated with the host clipboard when possible, so Kōtuku applications can exchange those datatypes with native Windows applications. If CPF::HISTORY_BUFFER is enabled, the clipboard actively monitors host changes and caches copied data in the local clipboard: volume. This enables limited history at the cost of additional monitoring and storage overhead.
On Linux and other non-Windows builds, clipboard storage is local to Kōtuku applications unless platform-specific host integration is supplied by the display driver.
When history buffering is active, a fixed number of clip groups is retained and the oldest group is removed when the limit is exceeded. Cached clipboard files are kept under clipboard: and stale generated files are cleaned up during display initialisation.
The Clipboard class consists of the following fields:
Access | Name | Type | Comment | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
| Flags | CPF | Optional clipboard behaviour flags. | |||||||||
| |||||||||||
| RequestHandler | FUNCTION | Callback for drag-and-drop data requests. | |||||||||
When the clipboard is in drag-and-drop mode, applications can request source data by sending a The callback uses this signature:
The callback is expected to send a | |||||||||||
The following actions are currently supported:
| Clear | Removes all cached clipboard data. | |||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
ERR acClear(*Object) Clear deletes the generated clipboard cache and removes all clip records tracked by the current process. Use Remove() to delete only selected datatypes. | ||||||||||||||||||||||||
| DataFeed | Sends data to the clipboard or handles drag-and-drop requests. | |||||||||||||||||||||||
ERR acDataFeed(*Object, OBJECTID Object, DATA Datatype, std::span<const int8_t> Buffer)
For regular clipboard writes, DataFeed currently accepts When the clipboard is in drag-and-drop mode, DataFeed also accepts Error Codes
| ||||||||||||||||||||||||
The following methods are currently supported:
| AddFile | Adds a file reference to the clipboard. | ||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
ERR clip::AddFile(OBJECTPTR Object, CLIPTYPE Datatype, STRVIEW Path, CEF Flags) Use AddFile() when the data to copy is already available as a file. The method stores the file path as a clipboard entry and associates it with a If the clipboard can publish the file reference to the host platform, and history buffering is disabled, the method may return after updating the host clipboard. Otherwise the file reference is recorded in the Kōtuku clipboard store. Recognised data types are:
Optional flags that may be passed to this method are as follows:
Error Codes
| |||||||||||||||||||||||||||
| AddObjects | Saves objects to clipboard cache files. | ||||||||||||||||||||||||||
ERR clip::AddObjects(OBJECTPTR Object, CLIPTYPE Datatype, OBJECTID * Objects, CEF Flags) Use AddObjects() to copy one or more objects by asking each object to save itself to a generated file in the If All objects in a single call must belong to the same class. The Optional flags that may be passed to this method are the same as those specified in the AddFile() method. The Error Codes
| |||||||||||||||||||||||||||
| AddText | Adds a block of text to the clipboard. | ||||||||||||||||||||||||||
ERR clip::AddText(OBJECTPTR Object, STRVIEW String)
Use AddText() to place plain UTF-8 text on the clipboard. Empty strings are ignored and return On Windows, the text is also published to the host clipboard when supported. If history buffering is disabled and the host clipboard accepts the text, no local cache file is created. Error Codes
| |||||||||||||||||||||||||||
| GetFiles | Retrieve the most recently clipped data as a list of files. | ||||||||||||||||||||||||||
ERR clip::GetFiles(OBJECTPTR Object, CLIPTYPE Filter, INT Index, CLIPTYPE * Datatype, kt::vector<std::string> * Files, CEF * Flags)
GetFiles() returns clipboard entries as readable file paths. The caller can request a specific set of datatypes through Without history buffering, only the most recent clip group is available. With history buffering enabled, pass On success, If Error Codes
| |||||||||||||||||||||||||||
| Remove | Removes selected datatypes from the clipboard. | ||||||||||||||||||||||||||
ERR clip::Remove(OBJECTPTR Object, CLIPTYPE Datatype)
Remove() clears all active clip groups whose datatype matches Error Codes
| |||||||||||||||||||||||||||
| Name | Description |
|---|---|
| CEF::DELETE | Requests that the original file source is deleted if a successful paste operation takes place. |
| CEF::EXTEND | Instead of replacing existing clipboard data, add the new data to the group. |
Clipboard types
| Name | Description |
|---|---|
| CLIPTYPE::AUDIO | An audio clip that is recognised by the Sound class (such as wav's and mp3's). |
| CLIPTYPE::DATA | Raw information that is uncategorised can be defined as a data clip. |
| CLIPTYPE::FILE | Pure file references are stored as file clips. This type is typically used by file managers for moving and copying files. |
| CLIPTYPE::IMAGE | Images that are recognised by the Image class may be stored as this type (such as jpeg's and png files). |
| CLIPTYPE::OBJECT | An object that has been deserialised into binary form. |
| CLIPTYPE::TEXT | Plain text files such as ASCII and UTF-8 must be identified through this clip type. |
Clipboard flags
| Name | Description |
|---|---|
| CPF::DRAG_DROP | Enables drag and drop mode. The clipboard content will be private and not share data with the host system in this mode. |
| CPF::HISTORY_BUFFER | Enables the history buffer. Note that this results in active clipboard monitoring and the program will make copies of all potential clipboard content - whether it is used or not. |
| CPF::HOST | This indicator is automatically set when a clipboard was created due to incoming content from the host system. |