2

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]];
        }


    }

}
Javier Beltrán
  • 756
  • 5
  • 26

2 Answers2

0

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

jscs
  • 63,694
  • 13
  • 151
  • 195
  • With this i edit the field but I still can't to move to next or previous cell – Javier Beltrán Jun 24 '11 at 21:54
  • I don't understand what you're trying to do. – jscs Jun 25 '11 at 07:09
  • I want to move between cells using right and left arrow keys like tab and shift-tab, so when i press right i should move to the next cell and edit it – Javier Beltrán Jun 29 '11 at 13:30
  • What do you mean, "move between cells?" If you use this method, it will select and open for editing any cell you indicate. Use the same logic you already have to select the next row or column. – jscs Jun 29 '11 at 17:56
0

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

Community
  • 1
  • 1
quarac
  • 3,454
  • 3
  • 21
  • 25