The Clipboard class manages cut, copy and paste between applications.
The Clipboard class manages data transfer between applications on behalf of the user. Depending on the host system, behaviour between platforms can vary.
On Windows the clipboard is tightly integrated by default, allowing it to support native Windows applications. This reduces the default feature set, but ensures that the clipboard behaves in a way that the user would expect it to. If historical buffering is enabled with the CPF::HISTORY_BUFFER
option then the clipboard API will actively monitor the clipboard and store copied data in the local clipboard:
file cache. This results in additional overhead to clipboard management.
On Linux the clipboard is localised and data is shared between Parasol applications only.
Multiple clipboard objects can be created, but they will share the same group of clipped data for the logged-in user.
There is a limit on the number of clipped items that can be stored in the clipboard. Only 1 grouping of each datatype is permitted (for example, only one group of image clips may exist at any time). In historical buffer mode there is a fixed limit to the clip count and the oldest members are automatically removed.
The Clipboard class consists of the following fields:
The following actions are currently supported:
Name | Comment | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
Clear | Destroys all cached data that is stored in the clipboard. | |||||||||||
DataFeed | This action can be used to place data in a clipboard. | |||||||||||
ERR acDataFeed(*Object, OBJECTID Object, DATA Datatype, APTR Buffer, LONG Size)
Data can be sent to a clipboard object via the DataFeed action. Currently, only the |
The following methods are currently supported:
Name | Comment | ||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
AddFile | Add files to the clipboard. | ||||||||||||||||||||||||||
ERR clip::AddFile(OBJECTPTR Object, CLIPTYPE Datatype, CSTRING Path, CEF Flags) This method is used to add a file to the clipboard. You are required to specify the type of data that is represented by the file. This allows the file content to be pasted by other applications that understand the data. Adding files to the clipboard with a known datatype can be very efficient compared to other methods, as it saves loading the data into memory until the user is ready to paste the content. Recognised data types are:
Optional flags that may be passed to this method are as follows:
Error Codes
| |||||||||||||||||||||||||||
AddObjects | Extract data from objects and add it all to the clipboard. | ||||||||||||||||||||||||||
ERR clip::AddObjects(OBJECTPTR Object, CLIPTYPE Datatype, OBJECTID * Objects, CEF Flags) Data can be saved to the clipboard directly from an object if the object's class supports the SaveToObject() action. The clipboard will ask that the object save its data directly to a cache file, completely removing the need for the client to save the object data to an interim file for the clipboard. Certain classes are recognised by the clipboard system and will be added to the correct datatype automatically (for instance, Picture objects will be put into the This method supports groups of objects in a single clip, thus requires an array of object ID's terminated with a zero entry. 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, CSTRING String)
Plain UTF-8 text can be added to the clipboard using the AddText() method. Error Codes
| |||||||||||||||||||||||||||
GetFiles | Retrieve the most recently clipped data as a list of files. | ||||||||||||||||||||||||||
ERR clip::GetFiles(OBJECTPTR Object, CLIPTYPE Filter, LONG Index, CLIPTYPE * Datatype, CSTRING ** Files, CEF * Flags)
This method returns a list of items that are on the clipboard. The caller must declare the types of data that it supports (or zero if all datatypes are recognised). The most recently clipped datatype is always returned. To scan for all available clip items, set the On success this method will return a list of files (terminated with a If this method returns the Error Codes
| |||||||||||||||||||||||||||
Remove | Remove items from the clipboard. | ||||||||||||||||||||||||||
ERR clip::Remove(OBJECTPTR Object, CLIPTYPE Datatype)
The Remove() method will clear all items that match a specified datatype. Clear multiple datatypes by combining flags in the 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 Picture 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. |
Class Info | |
---|---|
ID | ID_CLIPBOARD |
Category | IO |
Include | modules/clipboard.h |
Version | 1 |