Important: The information in this document is obsolete and should not be used for new development.
Chapter 2 - Scrap Manager
This chapter describes how your application can allow the user to cut, copy, and paste data between documents or within a document by using the Scrap Manager. When you copy data, your application writes the data to a specific location, and your application writes the data using a standard format. The Scrap Manager makes this data available to other applications. Furthermore, when your application copies data such as text or graphics, you write the data using the standard formats that all Macintosh applications should support. By using standard formats, the user can copy and paste data between documents created by your application and others.The Scrap Manager supports the sharing of static data between applications. That is, once the data is pasted into another document, there is no connection between the data that was pasted and the original source of the data. To support dynamic sharing of data, where the user can copy data from one document into another document and receive automatic updating of the information when the data in the original document changes, use the Edition Manager. See Inside Macintosh: Interapplication Communication for information on the Edition Manager.
You can also support the copying and pasting of sounds, movies, publishers or subscribers, and other formats. For specific information on supporting sounds and movies, see Inside Macintosh: Sound and Inside Macintosh: QuickTime, respectively. For information on supporting publishers and subscribers, see the chapter "Edition Manager" in Inside Macintosh: Interapplication Communication.
If the Translation Manager is available, the Scrap Manager uses its services as necessary to translate data in one format into another format. For specific information on the Translation Manager, see the chapter "Translation Manager" in this book.
If your application uses only TextEdit for all text input, you can use TextEdit routines to cut, copy, and paste data. For complete information on TextEdit, see the chapter "TextEdit" in Inside Macintosh: Text.
To support the copying and pasting of data in dialog boxes, use Dialog Manager routines. See the chapter "Dialog Manager" in Inside Macintosh: Macintosh Toolbox Essentials for information on how to create and handle dialog boxes.
This chapter discusses the Edit menu commands Cut, Copy, and Paste. For specific information on how to create and handle menus in your application, see the chapter "Menu Manager" in Inside Macintosh: Macintosh Toolbox Essentials.
To use this chapter, you should be familiar with the Event Manager, in particular, how to handle suspend and resume events. See the chapter "Event Manager" in Inside Macintosh: Macintosh Toolbox Essentials for additional information on the Event Manager.
This chapter begins by describing how the copy-and-paste operation works and the user interface behind it. The chapter then discusses how you can
- get information about the current contents of the scrap
- read data from the scrap
- write data to the scrap
Chapter Contents
- Introduction to the Scrap Manager
- The Clipboard
- Intelligent Cut and Paste
- About the Scrap Manager
- Location of the Scrap
- Using the Scrap Manager
- Getting Information About the Scrap
- Putting Data in the Scrap
- Handling the Cut Command
- Handling the Copy Command
- Handling Suspend Events
- Getting Data From the Scrap
- Handling the Paste Command
- Handling Resume Events
- Converting Data Between a Private Scrap and the Scrap
- Converting Data Between the TextEdit Scrap and the Scrap
- Handling Editing Operations in Dialog Boxes
- Scrap Manager Reference
- Data Structures
- The Scrap Information Record
- The Scrap Format Types
- Routines
- Getting Information About the Scrap
- Writing Information to the Scrap
- Reading Information From the Scrap
- Transferring Data Between the Scrap in Memory and the Scrap on Disk
- Summary of the Scrap Manager
- Pascal Summary
- Constants
- Data Types
- Routines
- C Summary
- Data Types
- Routines
- Assembly-Language Summary
- Data Structures
- Result Codes