Drag and drop between two table views.
Drag and drop between two table views.
- Subject: Drag and drop between two table views.
- From: Paul Johnson <email@hidden>
- Date: Mon, 25 Oct 2010 16:54:47 -0500
I am trying to drag and drop from one text view to another. I can write an
index set of copied rows to the pasteboard using:
- (BOOL)tableView:(NSTableView *)tv
writeRowsWithIndexes:(NSIndexSet *)rowIndexes
toPasteboard:(NSPasteboard*)pboard {
// Copy the row numbers to the pasteboard.
NSData *data = [NSKeyedArchiver archivedDataWithRootObject:rowIndexes];
[pboard declareTypes:[NSArray arrayWithObject:NSDragPboard] owner:self];
[pboard setData:data forType:NSDragPboard];
return YES;
}
In the array controller for the destination text view, I have
- (BOOL)tableView:(NSTableView *)aTableView
acceptDrop:(id <NSDraggingInfo>)info
row:(NSInteger)row
dropOperation:(NSTableViewDropOperation)operation
{
NSPasteboard* pboard = [info draggingPasteboard];
NSData* rowData = [pboard dataForType:NSDragPboard];
NSIndexSet* rowIndexes = [NSKeyedUnarchiver unarchiveObjectWithData
:rowData];
NSInteger dragRow = [rowIndexes firstIndex];
// Move the specified row to its new location...
NSLog(@"count = %i", [rowIndexes count]);
while(dragRow != NSNotFound)
{
NSLog(@" %i", dragRow);
dragRow = [rowIndexes indexGreaterThanIndex:dragRow];
// **** Copy a row here. ****
}
return YES;
}
I'm having trouble figuring out the correct code in the while-loop where I
need to copy a row.
As you can see, I'm new at this, but perhaps someone can lead me in the
right direction. Thanks.
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden