开发者

Make only a few columns of an NSTableView movable

开发者 https://www.devze.com 2023-01-05 21:31 出处:网络
In iTunes, you will see that the first two columns (the first narrow one containing nothing) and the second 开发者_Python百科one containing song name, are not movable. The others are movable.

In iTunes, you will see that the first two columns (the first narrow one containing nothing) and the second 开发者_Python百科one containing song name, are not movable. The others are movable.

How can I accomplish this with an NSTableView?


Implement the NSTableViewDelegate method tableView:shouldReorderColumn:toColumn: to control this behaviour. From the documentation:

When a column is initially dragged by the user, the delegate is first called with a newColumnIndex value of -1. Returning NO will disallow that column from being reordered at all. Returning YES allows it to be reordered, and the delegate will be called again when the column reaches a new location.


In your table view's delegate, respond to the tableView:shouldReorderColumn:toColumn: message. See the documentation at that link for exactly what your implementation must do.

0

精彩评论

暂无评论...
验证码 换一张
取 消