PDA

View Full Version : Reordering rows in a view-based NSTableVIew




monsieurpaul
Jul 18, 2012, 11:06 AM
Hello all,

I'm toying with the view-based NSTableView and I'm looking for a way of reordering rows by draging them with mouse.

However I can't find any documents/guides/tutorials about this.

Thank you,

Paul



GorillaPaws
Jul 19, 2012, 06:57 AM
Take a look at Apple's NSTableViewDataSource Protocol Reference (https://developer.apple.com/library/mac/#documentation/Cocoa/Reference/ApplicationKit/Protocols/NSTableDataSource_Protocol/Reference/Reference.html) under the "Drag and Drop" section. There is an Apple sample project called TableViewPlayground (http://developer.apple.com/library/mac/#samplecode/TableViewPlayground/Introduction/Intro.html#//apple_ref/doc/uid/DTS40010727) that implements a view-based drag/drop NSOutlineView, which is just a subclass of NSTableView, so you should be able to see how it's done there.

monsieurpaul
Jul 19, 2012, 08:21 AM
Take a look at Apple's NSTableViewDataSource Protocol Reference (https://developer.apple.com/library/mac/#documentation/Cocoa/Reference/ApplicationKit/Protocols/NSTableDataSource_Protocol/Reference/Reference.html) under the "Drag and Drop" section. There is an Apple sample project called TableViewPlayground (http://developer.apple.com/library/mac/#samplecode/TableViewPlayground/Introduction/Intro.html#//apple_ref/doc/uid/DTS40010727) that implements a view-based drag/drop NSOutlineView, which is just a subclass of NSTableView, so you should be able to see how it's done there.
Thanks for the input. Indeed, the TableViewPlayground and some documents form WWDC2011 were very helpful.