tags:

views:

170

answers:

3

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
I don't think Info.plist as to do with that. See my answer.
yogsototh
Actually, it does. Your answer involves accepting dropped objects into views, not dropped files onto the app icon.
Marc W
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
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
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
He's not talking about views, he's talking about dragging an onto an icon in the dock or on the desktop.
Amuck
Moreover, the document doesn't explain how a not launched application is able to accept or refuse drag-open operation.
mouviciel