diff options
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 |