When I click with the mouse I can get the cell position with myTableView.clickedRow
and myTableView.clickedColumn
.
However if I click on the first cell and then I press "Tab" key on my keyboard, the selection will stay on row = 0
and column = 0
.
Is there a way to track the row and column index when changing cell with keyboard ?
When a text field in a cell is focused then the first responder is the field editor of the text field. Use row(for:)
and column(for:)
of NSTableView
to get the row and column.
if let view = window.firstResponder as? NSView {
let column = tableView.column(for: view)
let row = tableView.row(for: view)
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.