我想用右箭头和左箭头模拟标签和shift-tab。我假设我必须继承NSTableview并覆盖keydown代码,但我不知道如何告诉必须编辑列和行中的单元格的表视图。这是我有多远
-(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]];
}
}
}
答案 0 :(得分:0)
答案 1 :(得分:0)
优于keydown,您可以从NSTableView覆盖NSControl委托:
- (BOOL)control:(NSControl *)control textView:(NSTextView *)textView doCommandBySelector:(SEL)command
看一下这篇文章的答案:Arrow keys with NSTableView