Unfortunately it doesn't work. What are the possible reasons why writeRows won't be called when initiating a drag in an NSOutlineView? (I've taken a look at the DragNDropOutlineView example which works fine for me but comparing implementations suggests nothing obvious). This is with XCode 2.0 and Tiger, incidentally.
Here's a bit of code that will allow drag and drop in a tableView. It is very basic...but writeRows is called.
--corbin
NSArray *a = nil;
- (void)awakeFromNib { [testTableView registerForDraggedTypes:[NSArray arrayWithObjects:NSStringPboardType, nil]]; }
- (int)numberOfRowsInTableView:(NSTableView *)tableView { if (a == nil) { a = [NSArray arrayWithObjects:@"hi", @"test", @"another", @"foo", @"Bar", @"tasdfsdf", @"asdflksjf", @"asdfsdf", @"asfds", nil]; [a retain]; } return [a count]; }
- (id)tableView:(NSTableView *)tableView objectValueForTableColumn:(NSTableColumn *)tableColumn row:(int)row { return [a objectAtIndex:row]; }
- (BOOL)tableView:(NSTableView *)tv writeRowsWithIndexes:(NSIndexSet *)rowIndexes toPasteboard:(NSPasteboard*)pboard { NSLog(@"write rows"); return YES; }
- (NSDragOperation)tableView:(NSTableView*)tv validateDrop:(id <NSDraggingInfo>)info proposedRow:(int)row proposedDropOperation:(NSTableViewDropOperation)op { return NSDragOperationCopy | NSDragOperationGeneric; }
- (BOOL)tableView:(NSTableView*)tv acceptDrop:(id <NSDraggingInfo>)info row:(int)row dropOperation:(NSTableViewDropOperation)op { return YES; } |