diff options
author | rowanbeentje <rowan@beent.je> | 2011-04-25 23:57:57 +0000 |
---|---|---|
committer | rowanbeentje <rowan@beent.je> | 2011-04-25 23:57:57 +0000 |
commit | 75e4e58eecf4ae1b8f25751b0bc7d457edcf57e8 (patch) | |
tree | 964b60108a9f41ba1adba08f82846911fd676ea8 /Source/SPTableView.m | |
parent | 25268f100c5f1b90ed5944b0123748d8a152b040 (diff) | |
download | sequelpro-75e4e58eecf4ae1b8f25751b0bc7d457edcf57e8.tar.gz sequelpro-75e4e58eecf4ae1b8f25751b0bc7d457edcf57e8.tar.bz2 sequelpro-75e4e58eecf4ae1b8f25751b0bc7d457edcf57e8.zip |
- Add the ability to double-click in empty areas of the main tableviews to add new rows/records
Diffstat (limited to 'Source/SPTableView.m')
-rw-r--r-- | Source/SPTableView.m | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/Source/SPTableView.m b/Source/SPTableView.m index d678fef3..9139bb79 100644 --- a/Source/SPTableView.m +++ b/Source/SPTableView.m @@ -34,10 +34,34 @@ @end +@interface SPTableView (PrivateAPI) + +- (void)_doubleClickAction; + +@end + + @implementation SPTableView @synthesize tabEditingDisabled; +- (id) init +{ + if ((self = [super init])) { + emptyDoubleClickAction = NULL; + } + return self; +} + +- (void) awakeFromNib +{ + [super setDoubleAction:@selector(_doubleClickAction)]; + if ([NSTableView instancesRespondToSelector:@selector(awakeFromNib)]) + [super awakeFromNib]; +} + +#pragma mark - + /** * Right-click at row will select that row before ordering out the contextual menu * if not more than one row is selected. @@ -193,4 +217,25 @@ } } +- (void)setEmptyDoubleClickAction:(SEL)aSelector +{ + emptyDoubleClickAction = aSelector; +} + +@end + + +@implementation SPTableView (PrivateAPI) + +/** + * On a double click, determine whether the action was in the empty area + * of the current table; if so, perform the assigned emptyDoubleClick action. + */ +- (void)_doubleClickAction +{ + if ([super clickedRow] == -1 && [super clickedColumn] == -1 && emptyDoubleClickAction) { + [[self delegate] performSelector:emptyDoubleClickAction]; + } +} + @end |