Skip to content

Instantly share code, notes, and snippets.

@mrjjwright
Created October 26, 2009 03:32
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mrjjwright/218405 to your computer and use it in GitHub Desktop.
Save mrjjwright/218405 to your computer and use it in GitHub Desktop.
Select first row in NSTableView on focus
//put this in subclass of NSTableView
//select the first row or blue highlights already selected rows
//in a NSTableView when we gain focus if there are rows in the table
-(BOOL) becomeFirstResponder {
if ([self numberOfRows] > 0 && [self numberOfSelectedRows] == 0) {
[self selectRowIndexes:[NSIndexSet indexSetWithIndex:0] byExtendingSelection:NO];
}
[self setNeedsDisplay];
return YES;
}
@jzau
Copy link

jzau commented Mar 7, 2016

just uncheck allow no selection in storyboard should work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment