NSTableView Drag and Drop doesn't work
NSTableView Drag and Drop doesn't work
- Subject: NSTableView Drag and Drop doesn't work
- From: Jushin <email@hidden>
- Date: Tue, 17 Mar 2009 11:04:57 -0400
In MyDocument.xib, I have a table and an array list (dataList) for data source.
Then I created a subclass of NSArrayController (dataListController)
and linked the array list (dataList) to this class.
And in the dataListcontroller, I made an outlet of the table and made
a connection.
Ok, that's my setup.
Now, I want to implement drag and drop for the table.
So, I added followings to the dataListController class.
- (void)awakeFromNib {
[tableView setDraggingSourceOperationMask:NSDragOperationLink forLocal:NO];
[tableView setDraggingSourceOperationMask:(NSDragOperationCopy |
NSDragOperationMove) forLocal:YES];
[tableView registerForDraggedTypes:types];
[tableView setAllowsMultipleSelection:YES];
[super awakeFromNib];
}
- (BOOL)tableView:(NSTableView *)aTableView
writeRowsWithIndexes:(NSIndexSet *)rowIndexes
toPasteboard:(NSPasteboard *)pboard {
NSLog(@"drag1");
return YES;
}
- (NSDragOperation)tableView:(NSTableView*)tv validateDrop:(id
<NSDraggingInfo>)info proposedRow:(int)row
proposedDropOperation:(NSTableViewDropOperation)op {
NSDragOperation dragOp = NSDragOperationCopy;
NSLog(@"drag2");
return dragOp;
}
- (BOOL)tableView:(NSTableView*)tv acceptDrop:(id
<NSDraggingInfo>)info row:(int)row
dropOperation:(NSTableViewDropOperation)op {
NSLog(@"drag3");
return NO;
}
For now, as you can see, I just put NSLog whether the table receives
drag and drop action.
However, none of the NSLog message was printed out.
It looks like the drag and drop doesn't work at all.
What else should I do to make it work?
_______________________________________________
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