• 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 to be a drag source for the files ?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

How to be a drag source for the files ?


  • Subject: How to be a drag source for the files ?
  • From: Quentin Mathé <email@hidden>
  • Date: Mon, 14 Oct 2002 02:12:59 +0200

I have tried to implemented the files drag n' drop from NSTableView to other applications like the Finder but without success. When I drag a row from the table view to the Finder, the drag image appears but the drop doesn't occur, the drag image slides back. Here is the code from the table view data source :

- (BOOL)tableView:(NSTableView *)tv writeRows:(NSArray*)rows toPasteboard:(NSPasteboard*)pboard
{
NSArray *types;
NSMutableArray *selectedFiles = [[NSMutableArray alloc] init];
NSEnumerator *e = [rows objectEnumerator];
NSNumber *number;
int i;

while (number = [e nextObject]) {
i = [number intValue];
[selectedFiles addObject:[files objectAtIndex:i]]; // "files" is an array filled with files paths
}

types = [NSArray arrayWithObjects:NSFilenamesPboardType, @"self", nil];

[pboard declareTypes:types owner:nil];
[pboard setPropertyList:selectedFiles forType:NSFilenamesPboardType];

return YES;
}

Is anybody having an idea about where is the problem

--
Quentin Mathi
email@hidden
_______________________________________________
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: Scrolling TextViews
  • Next by Date: Re: { Semi-Newbie } Inverse of +initialize?
  • Previous by thread: Solved! Re: Outlineview conundrum
  • Next by thread: Custom NSWindow Subclass
  • Index(es):
    • Date
    • Thread