Chapter 23. Clipboard

The clipboard, or scrap as it is technically known, is where data goes when it is cut or copied, so that it can be pasted later. There is exactly one scrap, and it is available at system level; that’s why you can copy from one application and paste into another.

A distinction is sometimes made between the public scrap (the system scrap) and the private scrap of a particular application. These terms do not necessarily imply that there are actually two different scraps; they have to do more with the format of the scrap data. The question is whether what’s on the scrap is intended for public consumption. An application might maintain a private scrap because it needs to be able to copy and paste data in formats unique to itself. It might use the system scrap for this, or it might operate by some other mechanism. Nonetheless, all applications, when they are suspended, are expected to convert their current private scrap data, if any, to a form that other applications can read, on the system scrap. This is to make sure there is a seamless user experience of cutting and pasting within an application and cutting and pasting between applications.

Scrap data is identified rather like a resource (see Section 21.6), except that the scrap makes available only one instance of any given datatype at a time. The public scrap data formats are, minimally, 'TEXT' and 'PICT', and optionally, 'styl', 'snd', and 'movv'. Apart from these, scrap data formats may be regarded ...

Get REALBasic: TDG, 2nd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.