How drag files from an NSTableView?
How drag files from an NSTableView?
- Subject: How drag files from an NSTableView?
- From: Uli Kusterer <email@hidden>
- Date: Wed, 7 May 2003 23:52:21 +0200
Hi,
I have an NSTableView that lists some objects, to each of which
belongs a file. Now I want the user to be able to drag an item from the
list to e.g. drag the file to the Finder. However, the Finder doesn't
seem to see my file. I found no docs and no sample code on this, and
Hillegass doesn't demonstrate how to drag files. Anybody know what's
wrong with my code?
-(BOOL) tableView: (NSTableView *)tv writeRows: (NSArray*)rows
toPasteboard: (NSPasteboard*)pboard
{
NSNumber* theRow = [rows objectAtIndex:0];
Slide* slide = [presentation getSlideAtIndex: [theRow intValue]];
NSString* slidePath;
NSString* pasteboardType;
NSArray* types;
NSArray* files;
slidePath = [self makeSlidePath: slide];
pasteboardType = NSCreateFilenamePboardType( [slidePath pathExtension]
);
[pasteboardType autoRelease];
// types = [NSArray arrayWithObject: pasteboardType];
files = [NSArray arrayWithObject: slidePath];
[pboard declareTypes: types owner: nil];
[pboard setPropertyList: files forType: pasteboardType];
//[pboard setString: slidePath forType: pasteboardType];
NSLog(@"File dragged %@, extension %@, pasteboard type %@",
slidePath, [slidePath pathExtension], pasteboardType );
return YES;
}
The data that is output by the NSLog call looks valid:
2003-05-07 23:40:10.940 foo[1716] File dragged
/Users/witness/Movies/Myst3-Promo.mov, extension mov, pasteboard type
NSTypedFilenamesPboardType:mov
Cheers,
-- M. Uli Kusterer
http://www.zathras.de
_______________________________________________
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.