Created
October 26, 2009 04:08
-
-
Save mrjjwright/218416 to your computer and use it in GitHub Desktop.
Ignore tabs and enters in editable NSTableView
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//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