How to get index of currently selected row and column in NSTableView

不打扰是莪最后的温柔 提交于 2019-12-25 02:18:15

问题


I'm working on a small MacOS app with a super simple NSTableView. When the user select a cell I need to know the column and the row index of this cell. I've implemented the method

- (void)tableViewSelectionDidChange:(NSNotification *)notification

and ask to the NSTableView for selectedColumn and selectedRow, but when I click on the table the result is always the selection of an entire Row. (in fact selectedRow return the right index number and selectedColumn return -1 = no selection)

How can I select a single Cell and how can I know his coordinates?

Thanks for any help!

The selected row


回答1:


For a grid or spreadsheet type layout it is better to use an NSCollectionView.

See the documentation for more info.



来源:https://stackoverflow.com/questions/50722758/how-to-get-index-of-currently-selected-row-and-column-in-nstableview

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!