From 197bdf82287bacd91dd05aa1bbd85c50c7b0127d Mon Sep 17 00:00:00 2001 From: Tom Robinson Date: Wed, 18 Feb 2009 18:42:43 -0800 Subject: [PATCH] CPTableView doubleAction, clickedRow, clickedColumn methods --- AppKit/CPTableView.j | 38 +++++++++++++++++++++++++++++++++++--- 1 file changed, 35 insertions(+), 3 deletions(-) diff --git a/AppKit/CPTableView.j b/AppKit/CPTableView.j index 233c15a2e..47f842f18 100644 --- a/AppKit/CPTableView.j +++ b/AppKit/CPTableView.j @@ -815,7 +815,7 @@ var _CPTableViewWillDisplayCellSelector = 1 << 0, - (int)columnAtPoint:(CGPoint)aPoint { - var index = [self _columnAtY:aPoint.x] + var index = [self _columnAtX:aPoint.x] if (index >= 0 && index < _numberOfColumns) return index; @@ -1020,6 +1020,28 @@ var _CPTableViewWillDisplayCellSelector = 1 << 0, [self trackSelection:anEvent]; } +/* + Sets the message to be sent to the target when a cell is double clicked + @param aSelector the selector to be performed +*/ +- (void)setDoubleAction:(SEL)aSelector +{ + _doubleAction = aSelector; +} +- (SEL)doubleAction +{ + return _doubleAction; +} + +- (int)clickedColumn +{ + return _clickedColumn; +} +- (int)clickedRow +{ + return _clickedRow; +} + /* @ignore */ @@ -1031,13 +1053,23 @@ var _CPTableViewWillDisplayCellSelector = 1 << 0, if (type == CPLeftMouseUp) { + _clickedRow = [self rowAtPoint:point]; + _clickedColumn = [self columnAtPoint:point]; + if ([anEvent clickCount] === 2) { CPLog.warn("edit?!"); + + [self sendAction:_doubleAction to:_target]; } - else if (![_previousSelectedRowIndexes isEqualToIndexSet:_selectedRowIndexes]) + else { - [[CPNotificationCenter defaultCenter] postNotificationName:CPTableViewSelectionDidChangeNotification object:self userInfo:nil]; + if (![_previousSelectedRowIndexes isEqualToIndexSet:_selectedRowIndexes]) + { + [[CPNotificationCenter defaultCenter] postNotificationName:CPTableViewSelectionDidChangeNotification object:self userInfo:nil]; + } + + [self sendAction:_action to:_target]; } return;