Ok so the problem was that I missed the part about letting the table view know it should allow external drag operations... :)

In the initialization code I added: @applicationsTableView .setDraggingSourceOperationMask_forLocal(OSX::NSDragOperationGeneric, false) And now it works great. Dragging a row onto a texteditor opens the file at the path I return in tableView_writeRowsWithIndexes_toPasteboard.

Cheers,
Eloy

On 20 jun 2008, at 19:12, Eloy Duran wrote:

Hi,

I'm still very new to all the DND stuff, so here goes:

I want to be able to drag an item from my table view onto, for instance a texteditor, and have it open the file that the item represents. (Also having it drop on Terminal and inserting the path to the file would be nice, but that might be something completely different.)

Some stuff I tried in my table view data source is (RubyCocoa code btw):

def tableView_writeRowsWithIndexes_toPasteboard(tableView, rows, pboard)
   pboard.declareTypes_owner([OSX::NSFilenamesPboardType], self)
pboard.setPropertyList_forType(['/etc/hosts'], OSX::NSFilenamesPboardType)
   true
 end

OR:

def tableView_writeRowsWithIndexes_toPasteboard(tableView, rows, pboard)
   url = OSX::NSURL.URLWithString("/etc/hosts")
   pboard.addTypes_owner([OSX::NSURLPboardType], nil)
   url.writeToPasteboard pboard
   true
 end

So the drag operation is initiated, but that's only because I return true. Most stuff I read about dragging from the tableview is about promising files,
which, if I understand it correctly, is not what I need.

Does anyone know where in the docs I should RTFM?
Or a OSS app or example that implements such behaviour?

Kind regards,
Eloy

_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]

Reply via email to