Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 657
Matt S. Avatar asked Jan 23 '23 22:01

Matt S.


1 Answers

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.

like image 132
Joshua Nozzi Avatar answered Feb 02 '23 21:02

Joshua Nozzi