Resources for how to program an app that supports "Drag and drop" ?

Mike68k

Member
I'm doing a little development on my app. Just picked it up again after almost a year of hiatus since last release (it's been an eventful time..).

Anyway, I want to add some features to it that involve allowing the user to drag and drop an item from the finder (e.g. an application) into the window of my program and then do something with it and I'm looking for some direction on what area of the toolbox or Inside Macintosh to look into for this. I've been using Inside Macintosh for the better part of a year of developing (it aint much, I know, but the point is I'm not a complete noob to looking stuff up in there) but couldn't find anything obvious about this variety of 'drag and drop.' I found a bunch of 'drag and drop' related to AOCE - Apple Open Collaboration Environment and related Catalog stuff -- I admittedly didn't read through every bit of the possible parts but it just seems to be speaking towards stuff in the wrong direction to what I want.

Can anyone suggest some better spots to look for this sort of thing? To be clear, I'm not looking for dragging and dropping files onto my application icon from the Finder, I'm looking for supporting dragging and dropping a file from the finder onto a _window_ of my app.

Thanks as always!!

Edit to add:
I would have thought this was some sort of OS Event, described in apple events under interapplication communication...?
I spent a few minutes just now trying various apps I thought might support this sort of thing (i.e. in MS Word seeing if it supported dragging a SimpleText document from the finder onto an open Word document and seeing if it would extract the text and insert it into the document but no luck. Basically, I was seeing if any program supported this sort of functionality but no luck, yet.
 
Last edited:

joevt

Well-known member
Here's the first item in the list:
 

Attachments

  • DragMgrProgrammersGuide.pdf.zip
    320.7 KB · Views: 4

David Cook

Well-known member
I tried looking for this as well, good find!

If I may complain for a moment, the Drag Manager is a perfect example of how Apple development lost its way. 92 pages? Overly complicated and bloated.

The Scrap Manager, which is a parallel in the sense that it exchanges arbitrary data between programs, is only 14 pages.

Why didn't they simply add a new control type of 'DragAndDrop'. When the user performs a drag motion, you get a callback to fill in the equivalent of the 'drag scrap'. When the user hovers over before a drop, you get the equivalent of a callback to determine if you accept that type of 'drag scrap'. When they let go, you get the callback for the drop.
 

paws

Well-known member
I implemented drag and drop for my to do list application and it was a lot easier than it looked at first glance.
 

David Cook

Well-known member
I implemented drag and drop for my to do list application and it was a lot easier than it looked at first glance.

I'm sure you're right about that. Same thing for only implementing the required AppleEvents (Quit, Open, Print, and Application start). Nevertheless, sometimes just the appearance of complexity can prevent the adoption of a platform or technology.
 

Mike68k

Member
I implemented drag and drop for my to do list application and it was a lot easier than it looked at first glance.
Thanks for the encouraging tale!! Tell me more - was it really as easy as adding support for one additional apple event?

Haven’t gotten to look at the suggested literature from the other replies but will do.

Thanks all for the comments.
 

paws

Well-known member
I don't remember and I don't have the code at hand right now (disconnected tower machine), but I remember looking at the docs and thinking about dropping it, and then it turned out simple enough.
 
Top