Reputation: 1986
How do I start implementing the drag & drop capability in an NSTableView to re-order items like the one we see in OSX's Language & Text
preferences panel?
I can't find any references online. Maybe I am looking for it with the wrong keywords?
Maybe it is not even NSTableView, maybe I need to extend NSTableColumn or NSCell.
I am using XCode 4.2 in Snow Leopard.
Any help appreciated!
I attach an image from the mentioned panel to give an idea (dragging item "Deutsch" to the last position):
Upvotes: 0
Views: 1132
Reputation: 15035
Implement the following below method for drag and drop
1) - (BOOL)tableView:(NSTableView *)tv writeRows:(NSArray*)rows toPasteboard:(NSPasteboard*)pboard
2) - (NSArray *)namesOfPromisedFilesDroppedAtDestination:(NSURL *)dropDestination
3) - (void)draggedImage:(NSImage *)anImage endedAt:(NSPoint)aPoint operation:(NSDragOperation)operation
4) -(void)awakeFromNib
{
[tableView registerForDraggedTypes: [NSArray arrayWithObjects:NSPasteboardTypeString, nil]];
[tableView setDraggingSourceOperationMask:NSDragOperationEvery forLocal:NO];
}
Also in bindings connect your table to datasource of your fileowner
Upvotes: 2