Search code examples
cocoadrag-and-drop

Cocoa: create drop zone for files


I want to create a drag and drop zone (using an NSView) for ANY file in my cocoa app. How do I do it?


Solution

  • Read Drag and Drop Programming Topics for Cocoa. You want your custom view to be a "dragging destination". You'll need to understand the pasteboard and file path pasteboard types, how to subclass a view (a generic NSView for your own custom class, or an existing view like NSImageView) and add the appropriate dragging source methods.