SystemEdit
SystemEdit Pass Edit menu item selections to DAs
#include <Desk.h> Desk Manager
short editCmd ; 0=Undo, 2=Cut, 3=Copy, 4=Paste, 5=Clear
returns Was the command handled by a DA?
Call SystemEdit whenever a user selects Undo, Cut, Copy, etc., from your
Edit menu. It checks if the frontmost window is a system window (ie, a DA),
and if so, informs the DA to take the specified editing action. SystemEdit will
also make sure your scrap is copied to the System Scrap correctly.
editCmd identifies which Edit menu command selection was selected by the
user. It is one of the following constants, defined in Desk.h:
undoCmd (0) Request to undo most recent change
(1) ( reserved)
cutCmd (2) Cut something and put in scrap
copyCmd (3) Copy something to the scrap
pasteCmd (4) Paste something from the scrap to the document
clearCmd (5) Clear/delete something
Returns: a Boolean. It indicates whether or not a DA was frontmost and the
edit request was processed by it. It is one of:
FALSE (0) A DA is not frontmost. The request was intended for your
application and you should process it.
TRUE (1) A DA is frontmost. It has handled the request.

Notes: When a user presses Z, X, C, or V, the Desk Manager
automatically routes the request to the application or the DA ( whichever
owns the frontmost window). But if these edit commands are selected from
a menu, you must call SystemEdit to ensure the DA gets a look at them.
The values for editCmd correspond to the positions of these commands in a
standard Edit menu; i.e., the topmost item is Undo, then a disabled
separator line, then Cut, and so forth. However, the editCmd values are 1
less than the corresponding item number. Thus, typical usage is to
ascertain the item number and subtract one from it in the call to
SystemEdit, as in the following sequence:
short theMenu, theItem;
long mr;
EventRecord theEvent;
WindowRecord whichWindow;
if(WaitNextEvent(everyEvent, & theEvent, 0, nil)) {
if ( theEvent.what == mouseDown ) {
switch ( FindWindow( theEvent.where, & whichWindow ) ) {
case inMenuBar:
mr = MenuSelect( theEvent.where ); /* user interaction */
theMenu = HiWord( mr );
theItem = LoWord( mr );
if ( theMenu == EDIT_MENU ) { /* in Edit menu? */
if ( SystemEdit( theItem-1) == FALSE ) {/* note -1 */
/* the menu command was meant for you; process it here */
switch( theItem ) {
case UNDO_ITEM: /*... process undo ... */
case CUT_ITEM: /* ... process cut ... */
/* ... etc ... */
} /* end of switch */
}
}
break;
case inContent:
/* ... etc ... */
}
}
}