Legacy Documentclose button

Important: The information in this document is obsolete and should not be used for new development.

Previous Book Contents Book Index Next

Inside Macintosh: More Macintosh Toolbox /
Chapter 2 - Scrap Manager / Using the Scrap Manager

Handling Editing Operations in Dialog Boxes

You can use the Dialog Manager to handle most editing operations in dialog boxes. In general, use the procedures DialogCut, DialogCopy, and DialogPaste to support the Cut, Copy, and Paste commands in editable text items in your dialog boxes. As shown in Listing 2-2 on page 2-18 and Listing 2-5 on page 2-24, when the user chooses the Cut, Copy, or Paste command, the application-defined routine uses Dialog Manager routines to perform the editing operation.

The Dialog Manager uses TextEdit to perform the editing operation. TextEdit copies data between its private scrap and the editable text item in the dialog box. TextEdit uses a private scrap, which allows the user to copy and paste data between dialog boxes. However, your application must make sure the user can copy and paste data between your application's dialog boxes and its document windows. That is, when the user selects text in a document window and chooses Copy, then activates a dialog box and chooses Paste, the data previously copied from the document window should appear in the active editable text item. Your application is responsible for maintaining consistency between the scrap (or your application's private scrap) and TextEdit's private scrap.

If your application uses TextEdit for all text editing in its document windows, then you can easily allow the user to copy and paste between your application's document windows and its dialog boxes, as your application uses TECut, TECopy, and TEPaste for its document windows and DialogCut, DialogCopy, and DialogPaste (which in turn use TextEdit routines) for its dialog boxes. These routines all use TextEdit's private scrap, which maintains consistency of data between editing operations.

If your application does not use TextEdit for text handling in your document windows and uses a private scrap, then when the user activates a dialog box you should copy any text data in your private scrap to TextEdit's private scrap. When a document window becomes active, if there's data in TextEdit's private scrap, you should copy the data to your private scrap (or the scrap if your application doesn't use a private scrap).

Similarly, before displaying the Standard File Package's save dialog box, your application should copy any text data in its private scrap to the scrap. The Standard File Package reads the data from the scrap when the user chooses an editing operation and a standard file dialog box is active. So your application needs to put the text data (if any) from the last Cut or Copy command in the scrap before calling StandardPutFile.

Previous Book Contents Book Index Next

© Apple Computer, Inc.
6 JUL 1996