简体   繁体   English

在NSTableView中控制编辑

[英]Controlling editing in NSTableView

I have subclassed NSTableView and NSTableColumn, and I want to control processus of edition of the cells of the table. 我已经将NSTableView和NSTableColumn分为子类,并且我想控制表格单元格版本的进程。

I have 2 states for my table class: edition and nonedition. 我的表类有2种状态:版本和非版本。 whatever the state of the table, when the user select a row, the row has to be overlighted. 无论表的状态如何,当用户选择一行时,该行都必须突出显示。

if the table is in state edition, the controls corresponding to the selected row must be visible. 如果表处于状态编辑状态,则与所选行相对应的控件必须可见。

I use the function rowview to make this possible, but I have no success. 我使用功能rowview使之成为可能,但没有成功。 1 when I click on the text cell of a cell, the control appears always. 1当我单击一个单元格的文本单元格时,该控件始终出现。 2 when the rowview function is called, I don't understand the value of the row parameter. 2当调用rowview函数时,我不了解row参数的值。 Sometimes it is correct, sometimes it is incorrect. 有时它是正确的,有时它是不正确的。

is it someone who could hep me? 有人可以帮我吗?

I want to make precision: to simplyfy, in my subclassed NSTableView, I write this code: override func rowView(atRow row: Int, makeIfNecessary: Bool) -> NSTableRowView? { let aRow = super.rowView (atRow: row, makeIfNecessary: makeIfNecessary) if aRow != nil { Swift.print("rowview is called for row (row)") } return aRow } 我想提高精度:简单地说,在我的子类NSTableView中,我编写以下代码: override func rowView(atRow row: Int, makeIfNecessary: Bool) -> NSTableRowView? { let aRow = super.rowView (atRow: row, makeIfNecessary: makeIfNecessary) if aRow != nil { Swift.print("rowview is called for row (row)") } return aRow } override func rowView(atRow row: Int, makeIfNecessary: Bool) -> NSTableRowView? { let aRow = super.rowView (atRow: row, makeIfNecessary: makeIfNecessary) if aRow != nil { Swift.print("rowview is called for row (row)") } return aRow }

When I click on row 0, I have the following result: " rowview is called for row 1 " Then when I click on row 1: " rowview is called for row 1 rowview is called for row 0 rowview is called for row 2" 当我单击第0行时,我得到以下结果:“ 第1行调用了行视图 ”然后,当我单击第1行时:“ 第1行调用了行视图。第0行调用了行视图。第2行调用了行视图”

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM