
Q I've just implemented a DragDrawingProc. To start, I've tried simply to duplicate the default behavior of the Drag Manager (so it will look as if I had not in fact attached a DragDrawingProc). Unfortunately, when the user drags into a valid drop area and the potential drop receiver calls ShowDragHilite, my DragDrawingProc seems to be responsible for leaving a trail of pixels on the screen. What am I doing wrong?
A
This happens because Drag Manager does not always pass the entire "old"
or "new" region to the DragDrawingProc. Here's a function which mimics
what Drag Manager does when you don't attach a DragDrawingProc to a
DragReference before calling TrackDrag:
static pascal OSErr LikeDefaultDragDrawingProc
( DragRegionMessage message,
RgnHandle showRegion, Point showOrigin,
RgnHandle hideRegion, Point hideOrigin,
void *dragDrawingRefCon, DragReference theDragRef )
{
OSErr err = noErr;
RgnHandle xorMe;
long oldA5;
Pattern gray;
switch (message)
{
case dragRegionBegin:
oldA5 = SetA5 ((long) dragDrawingRefCon);
gray = qd.gray;
SetA5 (oldA5);
PenPat (&gray);
PenMode (notPatXor);
break;
case dragRegionDraw:
xorMe = NewRgn ( );
if (!(err = MemError ( )))
{
XorRgn (showRegion, hideRegion, xorMe);
PaintRgn (xorMe);
DisposeRgn (xorMe);
}
break;
case dragRegionHide:
PaintRgn (hideRegion);
break;
}
return err;
}
The call to XorRgn is the key. It's also very important to pass the correct value for the 'dragDrawingRefCon' to SetDragDrawingProc:
SetDragDrawingProc (dragRef,LikeDefaultDragDrawingProc, (void*)SetCurrentA5 ( ));
(The above works for 68K code; UniversalProcPtr creation omitted for simplicity.)
By the way, be careful not to mix the use of SetDragDrawingProc and SetDragImage. See Technote 1043:On Drag Manager Additions for details.
-- Pete Gontier
devsupport@apple.com
Technical
Support
Technical Q&A's
Previous Question |
Contents |
Next
Question
Main | Page One | What's New | Apple Computer, Inc. | Find It | Contact Us | Help