如何获取NSTableView中当前选定的行和列的索引 [英] How to get index of currently selected row and column in NSTableView

查看:498
本文介绍了如何获取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询问selectedColumnselectedRow,但是当我单击表时,结果始终是选择整个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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆