2
votes

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 performClickOnCellAtColumn:[self selectedColumn]+1 row:[self selectedRow]];
        }


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


    }

}
2

2 Answers

0
votes

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