我试图以编程方式获取这应该是正在编辑的单元中的一个column.identifier开始检测NSTableColumn选定单元格。我试图通过注册我NSViewController为NSControlTextDidBeginEditingNotification得到,当我得到通知我通过鼠标位置追踪数据:NSTableView的在电池版
var selectedRow = -1
var selectedColumn: NSTableColumn?
func editingStarted(notification: NSNotification) {
selectedRow = participantTable.rowAtPoint(participantTable.convertPoint(NSEvent.mouseLocation(), fromView: nil))
let columnIndex = participantTable.columnAtPoint(participantTable.convertPoint(NSEvent.mouseLocation(), fromView: nil))
selectedColumn = participantTable.tableColumns[columnIndex]
}
我的问题是,鼠标的位置是给我错误的数据,是有一种方法可以根据表格的位置获取鼠标位置,或者有更好的方法来获取这些信息吗?
PS。我的NSViewController是NSTableViewDelegate和NSTableViewDataSource,我的NSTableView是查看基于并连接到一个ArrayController更新正确,我可以去我的模型对象和检测更改在willSet或didSet属性,但我需要检测何时更改是由用户制作,这就是为什么我需要在NSTableView发生变化之前检测到变化。