Yi.
Yi.

Reputation: 322

Handle OSX Dock Drag N Drop

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 :-)

Upvotes: 7

Views: 4648

Answers (5)

Tom Crayford
Tom Crayford

Reputation: 527

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.

Upvotes: 3

Peter Hosey
Peter Hosey

Reputation: 96333

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).

Upvotes: 4

Yi.
Yi.

Reputation: 322

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.

Upvotes: 6

Related Questions