Clipboard protocol
Factor handbook » UI framework » Implementing new gadgets

Prev:Implementing controls
Next:Gadget line support

Custom gadgets that wish to interact with the clipboard must use the following two generic words to read and write clipboard contents:
paste-clipboard ( gadget clipboard -- )

copy-clipboard ( string gadget clipboard -- )

UI backends can either implement the above two words in the case of an asynchronous clipboard model (for example, X11). If direct access to the clipboard is provided (Windows, macOS), the following two generic words may be implemented instead:
clipboard-contents ( clipboard -- string )

set-clipboard-contents ( string clipboard -- )

However, gadgets should not call these words, since they will fail if only the asynchronous method of clipboard access is supported by the backend in use.

Access to two clipboards is provided:


These variables may contain clipboard protocol implementations which transfer data to and from the native system clipboard. However an UI backend may leave one or both of these variables in their default state, which is a trivial clipboard implementation internal to the Factor UI.