【发布时间】:2011-02-18 22:56:11
【问题描述】:
这可能只是缺乏使用NSOutlineView 的经验,但我看不到这样做的方法。我有一个NSOutlineView(用出色的PXSourceList 实现),它带有一个添加按钮,在我正确保存/写入/插入/删除行方面完全可用。我不使用NSTreeController,也不使用绑定。我使用以下代码添加实体:
- (void)addEntity:(NSNotification *)notification {
// Create the core data representation, and add it as a child to the parent node
UABaseNode *node = [[UAModelController defaultModelController] createBaseNode];
[sourceList reloadData];
for (int i = 0; i < [sourceList numberOfRows]; i++) {
if (node == [sourceList itemAtRow:i]) {
[sourceList selectRowIndexes:[NSIndexSet indexSetWithIndex:i] byExtendingSelection:NO];
[sourceList editColumn:0 row:i withEvent:nil select:NO];
break;
}
}
}
当按下添加按钮时,会插入一个新行,如下所示:
如果我点击离开,然后选择该行并按enter 进行编辑,它现在看起来像这样:
我的问题是:我怎样才能以编程方式第一次获得相同的状态(焦点、选中、突出显示),以使用户体验更好?
【问题讨论】:
标签: cocoa nstableview nsoutlineview selectedindex pxsourcelist