NSFilenamesPboardType
NSFilenamesPboardType
- Subject: NSFilenamesPboardType
- From: Greg Casey <email@hidden>
- Date: Sun, 16 Feb 2003 14:31:10 -0500
Hi,
I have an NSTableView which lists a bunch of files. I want my user to
be able to drag any number of files from the NSTableView to the Finder
or another application (like mail). The files already exist and I have
their fully specified paths. Here's my version of
"tableView:writeRows:toPasteboard:"
- (BOOL)tableView:(NSTableView*)tv writeRows:(NSArray*)rows
toPasteboard:(NSPasteboard*)pboard
{
NSNumber *row;
NSMutableArray *filenames = [[NSMutableArray alloc] init];
NSEnumerator *e = [rows objectEnumerator];
// Collect the list of file paths to put on the pasteboard.
while (row = [e nextObject]) {
CCAsset *asset = [self assetAtIndex: [row intValue]];
[filenames addObject: [asset resolvedFilePath]];
}
NSLog(@"Filenames in list: %@", filenames);
// Now, put the filenames on the pasteboard.
[pboard declareTypes: [NSArray arrayWithObject: NSFilenamesPboardType]
owner: nil];
[pboard setPropertyList: filenames forType: NSFilenamesPboardType];
[filenames release];
return YES;
}
The NSLog call affirms that the "filenames" array contains x number of
string objects describing each file's full path. I've also checked to
make sure that the call to "[pboard setPropertyList:forType]" returns
YES and it does. I've also played with setting the owner to "self"
instead of nil, but that didn't change any behavior. So, it seems to me
like everything should work.
However, the Finder and other applications (like mail) do not respond
to the items being dragged or to drops. Can anyone see anything that I
might be missing here? NSFilenamesPboardType works with the Finder,
right? (I mean if the files already exist).
I'm running OS X 10.2.4, if that matters.
Thanks in advance for any tips,
-gtc
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.