DragAndDrop between binding controlled NSTableViews
DragAndDrop between binding controlled NSTableViews
- Subject: DragAndDrop between binding controlled NSTableViews
- From: Cornelius Jaeger <email@hidden>
- Date: Fri, 10 Dec 2004 00:50:12 +0100
hi all
i have a tableview for milestones, which is subclassed to MilestoneTableView.
Ditto for TaskTableView.
They are controlled by MilestoneDNDArrayController and TaskDNDArrayController.
One Milestone can have many Tasks.
Drag and Drop works fine, except for the case where i want to drag tasks from one milestone to the next.
I'm not sure how to implement this.
When i drag some tasks onto a milestone, the controllers don't update at all and the drop never happens.
In my MilestoneDNDArrayController I have code to handle Task drops like below (i've omitted the code for handlind Milestones cause it works (thanx mmalc)):
tasksController is an outlet wired to my milestoneController, but this doesn't feel right?
Help is much appreciated.
- (BOOL)tableView:(NSTableView*)tv acceptDrop:(id <NSDraggingInfo>)info row:(int)row dropOperation:(NSTableViewDropOperation)op
{
if (row < 0)
row = 0;
if ([[info draggingSource] class] == [TaskTableView class])
{
NSArray *newRows = [[info draggingPasteboard] propertyListForType:TaskMovedRowsType];
NSLog(@"getting newRows of tasks from pBoard: %@", newRows);
if (newRows)
{
NSRange range = NSMakeRange(row, [newRows count]);
NSIndexSet *indexSet = [NSIndexSet indexSetWithIndexesInRange:range];
[tasksController insertObjects:newRows atArrangedObjectIndexes:indexSet];
// set selected rows to those that were just copied
[tasksController setSelectionIndexes:indexSet];
return YES;
}
}
return NO;
}
regards
Cornelius
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden