在基于视图的NSOutlineView中为NSTextField代理事件? [英] Delegate events for NSTextField in a view-based NSOutlineView?
问题描述
我有一个完美的功能视图为基础的 NSOutlineView
与我的项目中正确的设置数据源。现在我想允许用户更改某些条目。所以我在IB可编辑的 NSTextField
中。对于基于单元格的 NSOutlineView
,可以使用委托方法 outlineView:setObjectValue:forTableColumn:byItem:
但是它不可用对于基于视图的 NSOutlineView
,如 NSOutlineViewData
协议的头文件中所述:
/ *基于视图的OutlineView:此方法不适用。 ($)
(void)outlineView:(NSOutlineView *)outlineView setObjectValue:(id)对象forTableColumn:(NSTableColumn *)tableColumn byItem:(id)item ;
所以我搜索了另一个委托方法,发现 outlineView:shouldEditTableColumn:item:
。但是,此委托方法不会被触发。可能是因为我没有编辑一个单元格。
所以我的问题是:有没有其他的方式来注意,一行更改,而不是每个 NSTextField
?
好吧,似乎苹果希望我们使用委托方法每个 NSTextField
如这里:
此方法适用于基于单元格的表视图,不能与基于视图的表视图一起使用。相反,目标/动作用于视图单元格中的每个项目。
所以目前还没有其他方法可以做到这一点。 >
I have a flawless functioning view-based NSOutlineView
with a proper set-up datasource in my project. Now I want to allow the user to change certain entries. So I made the NSTextField
in the IB editable. For a cell-based NSOutlineView
you can use the delegate method outlineView:setObjectValue:forTableColumn:byItem:
however it's not available for a view-based NSOutlineView
as stated in the header file for the NSOutlineViewData
protocol:
/* View Based OutlineView: This method is not applicable. */
(void)outlineView:(NSOutlineView *)outlineView setObjectValue:(id)object forTableColumn:(NSTableColumn *)tableColumn byItem:(id)item;
So I searched for another delegate method and found outlineView:shouldEditTableColumn:item:
. However this delegate method doesn't get fired. Probably because I'm not editing a cell.
So my question is: Is there any other way to notice when a row changed than having a delegate for each NSTextField
?
Well, it seems like Apple wants us to use the delegate methods of each NSTextField
as stated here:
This method is intended for use with cell-based table views, it must not be used with view-based table views. Instead target/action is used for each item in the view cell.
So there's currently no other way to do this.
这篇关于在基于视图的NSOutlineView中为NSTextField代理事件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!