Re: Dragging tableView rows to an external applications
Re: Dragging tableView rows to an external applications
- Subject: Re: Dragging tableView rows to an external applications
- From: Graham Cox <email@hidden>
- Date: Tue, 23 Sep 2008 22:22:43 +1000
On 23 Sep 2008, at 7:00 pm, Steve Cronin wrote:
Folks;
I'm trying in 10.4+ to implement dragging data from a tableView to
the desktop.
My problem is probably a dunderhead oversight but I can't see it.
I have NOT subclassed an NSTableView.
In a windowController I do the following in -awakeFromNib:
(myTableView is an Outlet)
...
[myTableView registerForDraggedTypes:[NSArray
arrayWithObjects:NSFilenamesPboardType, NSFilesPromisePboardType,
nil]];
[myTableView setDraggingSourceOperationMask:NSDragOperationNone
forLocal:YES]; //local
[myTableView setDraggingSourceOperationMask:NSDragOperationCopy
forLocal:NO]; // external
...
I get a local copy, drag some selected rows initiates a 'carrying'
cursor, but as soon as I leave my application it invalidates.
This is exactly the opposite of the desired/expected behavior...
NOTE: If I change both drag operations in the
setDraggingSourceOperation method to NSDragOperationEvery - no
difference.
myTableView has the windowController set as its delegate.
The tableView:writeRowsWithIndexes:toPasteboard is being called (its
in the windowController too)
What am I overlooking?
If I recall correctly (and I may not be, it's been a while) the Finder
will act upon the promised files type, ignoring the filenames type.
This being the case, if you promised the files, you have to make good
on that promise. From the docs regarding drag/drop in NSTableView:
"In Mac OS X v10.4, support was added for handling file-promised drag
operations in your data source object. To support this feature in a
table view, you must first promise the the data to the pasteboard
using the NSFilesPromisePboardType type in
yourtableView:writeRowsWithIndexes:toPasteboard: method. When a
destination accepts the dropped file information,NSTableView calls
through to the
tableView:namesOfPromisedFilesDroppedAtDestination:forDraggedRowsWithIndexes:method
of your data source to provide the files. Your implementation of
this method should create the files and return an array containing the
filenames (without path information)."
So does your datasource implement -
tableView:namesOfPromisedFilesDroppedAtDestination:forDraggedRowsWithIndexes
: ?
Have you actually written the promised files type in -
tableView:writeRowsWithIndexes:toPasteboard: ? If not, that might be
why you're not seeing the expected cursor.
hth,
Graham
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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:
This email sent to email@hidden