Sprocket Drag Mgr
Volume Number: 11
Issue Number: 4
Column Tag: Getting Started
Sprocket and the Drag Manager 
Adding an important technology to Sprocket
By Dave Mark, MacTech Magazine Regular Contributing Author
Note: Source code files accompanying article are located on MacTech CD-ROM orsource code disks.
This month’s column uses Sprocket to take the Drag Manager out for a quick spin.
I know we were originally scheduled to talk about Sprocket’s menuing model, but
we just couldn’t bring everything together in time. We’ll definitely get to it next
month.
If you’ve never used the Drag Manager before, bring up the Scrapbook and scroll
over to your favorite PICT. Now click on the PICT and drag it out of the Scrapbook
window. If you have the Drag Manager installed on your Mac (more on that in a
second), you’ll notice a grey rectangle (representing the PICT) following your mouse.
Drag the rectangle over any open Finder window. Each time your mouse enters a
window, a hilighting rectangle is drawn, telling you that this window is the focus of
this drag. If you move the mouse outside the window, the focus rectangle disappears.
This focus lets you know which window is to receive the object you are dragging
around. If you release the mouse button inside one of your Finder windows (or on the
desktop), a clipping file will be created. The clipping file contains the picture you
just dragged from the Scrapbook. If you double-click on a clipping file, the Finder
displays its contents in a window. If you drag the clipping file around, it acts just like
its contents. That is, if you drag a PICT clipping file, it is exactly as if you were
dragging the PICT contained in the file. Try it. Drag a Scrapbook PICT onto the
desktop, then drag the resulting clipping file back into the Scrapbook.
About the Drag Manager
Under System 7.5 or later, the Drag Manager is built right in. Earlier systems
required the installation of the Dragging Enabler extension or its replacement, the
Macintosh Drag and Drop extension (version 1.1 is the latest). No matter what System
you have, you’ll also need the Clipping Extension if you want the Finder to work with clipping files.
Apple has released a Drag Manager SDK, which contains everything you’ll need to
work with the Drag Manager, including some great sample code and two critical
DocViewer documents. The first of these, the Drag Manager Programmer’s Guide is
basically an Inside Macintosh chapter on the Drag Manager. The second document, Drag and Drop H.I. Guidelines, tells you how the Drag Manager is supposed to look to the
user.
If you’ve never worked with the Drag Manager before, there are two excellent
articles that will help ease you into the Drag Manager way of thinking. The first of
these, was written by Steve Kiene and appears in the June 1994 issue of MacTech Magazine (write to custservice@xplain.com to see if you can order the back issue).
The article is called “Macintosh Drag and Drop” and it takes you through the basic
Drag Manager concepts and terminology. The second article, “Drag and Drop From the
Finder” by Dave Evans and Greg Robbins appeared in the December 1993 issue of
develop (issue 16). This article has a slightly different slant than the MacTech article. If you can, read them both before you dive into the Programmer’s Guide. You
might also want to check out the article “Implementing Elegant Drag & Drop for Styled
Text Fields”, by David Simmons, in the November 1994 issue of MacTech. The article is based on SmallTalk, but is very readable even if you don’t speak the language.
This Month’s Program
This month’s program provides a basic demonstration of the Drag Manager. First,
we’ll create a new class called TPictureWindow. A TPictureWindow is a simple,
non-growable, non-zoomable, non-scrollable window with a PICT centered in it. The
TPictureWindow supports dragging in both directions. That is, you can drag a picture
into a TPictureWindow and you can drag a picture from a TPictureWindow as well.
Once our TPictureWindow class is added to our project, we’ll modify our code so
that a TPictureWindow is the default document type instead of a TDocWindow. This