Drag & Drop Reorder Rows on NSTableView

前端 未结 7 748
旧巷少年郎
旧巷少年郎 2020-12-08 11:21

I was just wondering if there was an easy way to set an NSTableView to allow it to reorder its rows without writing any pasteboard code. I only need it to be able to do thi

7条回答
  •  遥遥无期
    2020-12-08 11:58

    Unfortunately you do have to write the Paste board code. The Drag and Drop API is fairly generic which makes it very flexible. However, if you just need reordering it's a bit over-the-top IMHO. But anyway, 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

提交回复
热议问题