I just noticed that not all icons in the dock allows you to drag files to them. For example, I can drag a file to textedit but not finder. What exactly is it that decides whether or not an application supports an action like that? Just curious.
+5
A:
I believe it's the list of supported file types set in the application's Info.plist
. If you drag a supported file type onto the app, it will allow the drop. Otherwise it will not.
Marc W
2009-10-06 19:22:45
I don't think Info.plist as to do with that. See my answer.
yogsototh
2009-10-06 19:29:21
Actually, it does. Your answer involves accepting dropped objects into views, not dropped files onto the app icon.
Marc W
2009-10-06 19:42:34
Does all programs have a Info.plist? I'm thinking of multiplatform java programs for example. Though I dont know if they support this feature. But if they do, does that mean they also have a info.plist?
quano
2009-10-06 20:33:13
Iirc, old school Java-Cocoa bridge apps had one (but you might want to verify that yourself). Not sure about regular Java apps. I think they do have to do some platform-specific things to register handled document types, but I haven't done Java desktop app development in eons so I don't know the specifics.
Marc W
2009-10-06 20:35:17
A:
The application had to register itself to accept Drag'n Drop of certain kind of Data.
Before a view can receive a drag operation, you need to register the data types that it can accept by invoking its registerForDraggedTypes:, like this:
[self registerForDraggedTypes:[NSArray arrayWithObjects: NSColorPboardType, NSFilenamesPboardType, nil]];
The full details are here: http://developer.apple.com/mac/library/documentation/Cocoa/Conceptual/DragandDrop/DragandDrop.pdf
yogsototh
2009-10-06 19:27:35
+1
A:
See also this post:
http://stackoverflow.com/questions/501079/how-do-i-make-an-os-x-application-react-when-a-file-picture-etc-is-dropped-on-i
Ethan
2009-10-27 20:56:46