Skip to content

Instantly share code, notes, and snippets.

@mrjjwright
Created October 26, 2009 04:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mrjjwright/218416 to your computer and use it in GitHub Desktop.
Save mrjjwright/218416 to your computer and use it in GitHub Desktop.
Ignore tabs and enters in editable NSTableView
//put this in subclass of NSTableView
- (void)keyDown:(NSEvent *)theEvent {
//if user tabs in this table, we don't want to edit (the default)
//instead select the next view
if ([theEvent keyCode] == 48) {
if ([[self window] firstResponder] == self) {
[[self window] selectNextKeyView:self];
}
} else if ([theEvent keyCode] == 36){
//the user pushed enter
//in this case we want to not allow editing so we jsut
//pass this event on up the responder chain
[self doCommandBySelector:@selector(insertNewline:)];
}
else {
[super keyDown:theEvent];
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment