问题
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