开发者

Simulate Tab and Shift-Tab with arrow keys in NSTableView

I want to simulate tab and shift-tab with right arrow and left arrow. I suppossed I have to subclass NSTableview and overide keydown code but I don't know how to tell the table view that has to edit a cell in a column and row. this is how far i get

-(void)keyDown:(NSEvent*)event{
    [super keyDown:event];
    NSLog(@"%hi", [event keyCode]);

        if ([event keyCode] == 48 && ([event modifierFlags] &
                                  NSShiftKeyMask)){
        [[self window] selectKeyViewPrecedingView:self];
    }

    if ([event keyCode] == 51){
        [[self window] selectKeyViewPrecedingView:self];

    }
    if ([event keyCode] == 124){
        if ([self selectedColumn] < [self numberOfColumns]-1) {

            [self performC开发者_Go百科lickOnCellAtColumn:[self selectedColumn]+1 row:[self selectedRow]];
        }


    }
    if ([event keyCode] == 124){
        if ([self selectedColumn] > 0) {
            [self performClickOnCellAtColumn:[self selectedColumn]-1 row:[self selectedRow]];
        }


    }

}


Better than keydown, you can override the NSControl Delegate from the NSTableView:

- (BOOL)control:(NSControl *)control textView:(NSTextView *)textView doCommandBySelector:(SEL)command

Take a look at the answers from this post: Arrow keys with NSTableView


-[NSTableView editColumn:row:withEvent:select:]

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜