首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >基于NSOutlineView单元的从fieldEditor获取列

基于NSOutlineView单元的从fieldEditor获取列
EN

Stack Overflow用户
提问于 2016-12-17 15:32:06
回答 1查看 67关注 0票数 0

我有一个基于outlineView单元格的旧项目,如果其中一个单元格在"outlinView setObjectValue:“get之前的值不正确,我想要创建一个outlinView。我需要知道地点在哪里,我尝试过的是这样的成功:

代码语言:javascript
复制
- (BOOL)control:(NSControl *)control textShouldEndEditing:(NSText *)fieldEditor
{
    if ([control isEqualTo: myOutline]) {
        id item = [myOutline itemAtRow:[myOutline selectedRow]]; // ok
        NSInteger columnNum = [myOutline columnForView:fieldEditor];
        NSLog(@"columnNum = %ld", (long) columnNum); // bad, wrong column, it print 0 but the cell is at column 3
        TreeObj *data = (TreeObj *)[item representedObject];
        // .... rest of the code, return NO if the value is not correct ..

    }
    return YES;
}

"fieldEditor“似乎不利于找到正确的列,因为..its superview不是..its (??)所期望的。感谢您的建议,并随时发布快速代码。

(编辑)从@Willeke接受的更正代码:

代码语言:javascript
复制
- (BOOL)control:(NSControl *)control textShouldEndEditing:(NSText *)fieldEditor
{
    if ([control isEqualTo: myOutline]) {
        id item = [myOutline itemAtRow:[myOutline selectedRow]]; // ok
        NSTableColumn *tableCoumn = [[myOutline tableColumns] objectAtIndex:[myOutline editedColumn]];
        TreeObj *data = (TreeObj *)[item representedObject];
        if ([tableCoumn.identifier isEqualToString:@"theRightColumn"]) {
            // .... rest of the code, return NO if the value is not correct and display the alert..
        }


    }
    return YES;
}
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2016-12-17 16:21:22

编辑的行和列是属性editedRoweditedColumn of NSTableViewNSOutlineView的超类。您要查找的列是[myOutline editedColumn]myOutline.editedColumn

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/41200162

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档