I'm having a horrible time trying to implement drag and drop between two tables in the same app. I can get the source table to generate the drag and drag the item around, but I can't get the destination table to 'recognize' the drag. I'm trying to drag a dictionary from the source.
Here's how I implement the source drag code:
Code:
- (BOOL) tableView: (NSTableView *) view
writeRows: (NSArray *) rows
toPasteboard: (NSPasteboard *) pboard
{
NSLog(@"dragging");
id object = [[self arrangedObjects] objectAtIndex: [[rows lastObject] intValue]];
NSData *data = [NSArchiver archivedDataWithRootObject: object];
[pboard declareTypes: [NSArray arrayWithObject:@"PBtype"]
owner: nil];
[pboard setData: data forType:@"PBType"];
return YES;
}
Here is the message I send to the destination table to register it to receive the drag:
Code:
[destinationTableView registerForDraggedTypes: [NSArray arrayWithObjects:@"PBType", nil]];
I also implement the following methods in the datasource of the destination table:
Code:
- (NSDragOperation) tableView: (NSTableView *) view
validateDrop: (id <NSDraggingInfo>) info
proposedRow: (int) row
proposedDropOperation: (NSTableViewDropOperation) operation
AND
- (BOOL) tableView: (NSTableView *) view
acceptDrop: (id <NSDraggingInfo>) info
row: (int) row
dropOperation: (NSTableViewDropOperation) operation
Any ideas what I am doing wrong?
thanks,
kman