如何获取NSTableView中当前选定的行和列的索引 [英] How to get index of currently selected row and column in NSTableView
问题描述
我正在使用超简单的NSTableView开发一个小型MacOS应用程序. 当用户选择一个单元格时,我需要知道该单元格的列和行索引. 我已经实现了该方法
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
并向NSTableView询问selectedColumn
和selectedRow
,但是当我单击表时,结果始终是选择整个Row.
(实际上selectedRow
返回正确的索引号,而selectedColumn
返回-1 =无选择)
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)
如何选择一个单元格以及如何知道他的坐标?
感谢您的帮助!
推荐答案
对于网格或电子表格类型的布局,最好使用NSCollectionView
.
For a grid or spreadsheet type layout it is better to use an NSCollectionView
.
有关详细信息,请参见文档.
See the documentation for more info.
这篇关于如何获取NSTableView中当前选定的行和列的索引的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!