0

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):

enter image description here

5

1 Answer 1

2

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.