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: Programmer's Guide to MacApp / Part 1 - MacApp Theory and Architecture
Chapter 9 - Drag and Drop


Drag-and-Drop Initialization

To initialize MacApp drag-and-drop support, an application calls the InitUDragManager routine from its main routine, as shown in "Initializing Additional MacApp Units," beginning on page 92.

Initializing the Drag Session Object

The InitUDragManager routine creates the global drag session object, initializes it by calling the IDragDropSession method, and sets the static global field TDragDropSession::fgDragDropSession to refer to the object.

The IDragDropSession method sets up three procedure pointer fields that the drag session object can later install as callback routines for the Drag Manager. Each of the three fields points to a glue routine that sets up a failure handler and then calls a similarly named method of the drag session object.

For example, DragTrackingHandlerGlue sets up a failure handler, then calls fgDragDropSession->DragTrackingHandler to handle tracking during a drag session. It is necessary to set up failure handling in this way to prevent destroying the failure-handler list while in a Drag Manager callback.

Initializing View Drag Data

The TView class has fields that indicate whether a view object can initiate drags, whether it can accept drops, and whether dragged data should be moved or copied when it is dropped. By default, a view does not support dragging or dropping. An application can make a view draggable or droppable by setting these fields in code or by attaching a TDragDropBehavior object to the view in a resource template. You don't set these fields directly--you use accessor methods defined in the TView class.

The TView fields used with drag and drop are defined as follows:

Boolean
fDraggable;
Boolean
fDroppable;
short
fDragMoveDeterminer;
IDType
fDragMoveFamily;
The fDragMoveDeterminer and fDragMoveFamily fields, which determine whether dragged data should be copied or moved, are described more fully beginning on page 268.


Previous Book Contents Book Index Next

© Apple Computer, Inc.
25 JUL 1996