• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
How drag files from an NSTableView?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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.

  • Prev by Date: Re: Masking a Textfield
  • Next by Date: Menus with ALT a la Finder
  • Previous by thread: NSMovieView and NSMovie as surface Textures
  • Next by thread: Re: How drag files from an NSTableView?
  • Index(es):
    • Date
    • Thread