NSTableView hit tab to jump from row to row while editing

后端 未结 2 515
难免孤独
难免孤独 2021-02-10 06:27

I\'ve got an NSTableView. While editing, if I hit tab it automatically jumps me to the next column. This is fantastic, but when I\'m editing the field in the last column and I h

2条回答
  •  天涯浪人
    2021-02-10 07:08

    You can do this without subclassing by implementing control:textView:doCommandBySelector:

    -(BOOL)control:(NSControl *)control textView:(NSTextView *)textView doCommandBySelector:(SEL)commandSelector {
    
        if(commandSelector == @selector(insertTab:) ) {
            // Do your thing
            return YES;
        } else {
            return NO;
        }   
    }
    

    (The NSTableViewDelegate implements the NSControlTextEditingDelegate protocol, which is where this method is defined)

    This method responds to the actual keypress, so you're not constrained to the textDidEndEditing method, which only works for text cells.

提交回复
热议问题