tags:

views:

1061

answers:

4

I looked high and low for information on how to handle drag n drop to the dock in OSX. The drag n drop documentation (http://developer.apple.com/documentation/Cocoa/Conceptual/DragandDrop/DragandDrop.html#//apple_ref/doc/uid/10000069) I found all deal with dragging from view to view. If anyone can point me to some code samples, that would be excellent.

I'm writing my app using the PyObjC bride, but Cocoa examples would be equally welcome :-)

+2  A: 

Well, looks like I asked too soon. Here is a great tutorial that shows how one does it:

http://recurser.com/articles/2007/04/13/cocoa-drag-to-dock-to-open/

Basically, just set your controller to be the delegate of NSApplication and implement the openFile method.

Yi
You also need to add the document types your app handles in the properties of your target.
Guillaume
+2  A: 

Here's a similar question from a couple weeks ago. My answer covered dragging files, which is what you're talking about; the other answer covers dragging data, such as images and bits of text (not image files or text files, but bare data).

Peter Hosey
+1  A: 

http://lethain.com/entry/2008/aug/06/cocoa-drag-and-drop-text-into-the-dock-icon/ covers dragging and dropping text into a dock icon with pyobjc. You can adapt this into other files reasonably easily.

Tom Crayford
+1  A: 

An example project.

rpj