4

As per apple documentation drag and drop NSTableView delegate methods are called only for cell based TableViews not for View based. So there is no way to do reordering of rows using drag & drop for view based NSTableView?

Monolo
  • 18,205
  • 17
  • 69
  • 103
sach
  • 1,069
  • 4
  • 15
  • 29

2 Answers2

7

I have created a small sample project which has an NSOutlineView where you can add and remove items as well as reorder them. This is not an NSTableView but the implementation of the Drag & Drop protocol is basically identical.

I implemented drag and Drop in one go so it's best to look at this commit.

screenshot

Besi
  • 22,579
  • 24
  • 131
  • 223
  • Is that concept applicable to a NSCollectionView as well? I am just trying to reorder CollectionItems by drag and drop. Just curious … –  Mar 20 '14 at 09:09
  • 1
    I don't know at the top of my head. However I would assume that this should work there as well, but you'll have to test this. I know that the same concept applies for table views and source lists. – Besi Mar 20 '14 at 09:48
3

Drag and drop delegate methods get called fine in a view based NSTableView. There is a great presentation from WWDC '11 on view based table views, and it includes a lengthy discussion about drag and drop. Worth watching.

Link here - requires a login.

Kaunteya
  • 3,107
  • 1
  • 35
  • 66
Monolo
  • 18,205
  • 17
  • 69
  • 103