diff --git a/ChangeLog b/ChangeLog index fc1fb934f..362060787 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2004-09-12 Matt Rice + * Headers/AppKit/NSCell.h (-_sendsActionOn:): New method. + * Source/NSCell.m (-_sendsActionOn:): Implement it. + * Source/NSTextFieldCell.m (-initTextCell:): Change _action_mask to a + key press. + * Source/NSTableView.m (-mouseDown:): Use _sendsActionOn: to only modify + the object value and send the event to the cell if the cell works on + mouse events. (Fixes #9609). + 2004-09-12 Gregory John Casamento * Headers/NSDataLinkPanel.h: Added new attributes. diff --git a/Headers/AppKit/NSCell.h b/Headers/AppKit/NSCell.h index 26d6463b4..6eee820f9 100644 --- a/Headers/AppKit/NSCell.h +++ b/Headers/AppKit/NSCell.h @@ -456,6 +456,7 @@ typedef enum _NSControlSize { inFrame: (NSRect)aRect; - (void) _drawImage: (NSImage *)anImage inFrame: (NSRect)aRect isFlipped: (BOOL)flipped; +- (BOOL) _sendsActionOn:(int)eventTypeMask; @end // diff --git a/Source/NSCell.m b/Source/NSCell.m index 0b8acfeb4..b3e4de8c1 100644 --- a/Source/NSCell.m +++ b/Source/NSCell.m @@ -2213,6 +2213,10 @@ static NSColor *shadowCol; [anImage compositeToPoint: position operation: NSCompositeSourceOver]; } +- (BOOL) _sendsActionOn:(int)eventTypeMask +{ + return (_action_mask & eventTypeMask); +} @end diff --git a/Source/NSTableView.m b/Source/NSTableView.m index e4b3d7e21..0812277b6 100644 --- a/Source/NSTableView.m +++ b/Source/NSTableView.m @@ -3457,45 +3457,73 @@ inline float computePeriod(NSPoint mouseLocationWin, NSTableColumn *tb; NSCell *cell; NSRect cellFrame; + int actionMaskForCurrentEvent; + switch ([lastEvent type]) + { + case NSLeftMouseDown: + actionMaskForCurrentEvent = NSLeftMouseDownMask + | NSLeftMouseUpMask + | NSLeftMouseDraggedMask; + break; + case NSRightMouseDown: + actionMaskForCurrentEvent = NSRightMouseDownMask + | NSRightMouseUpMask + | NSRightMouseDraggedMask; + break; + case NSOtherMouseDown: + actionMaskForCurrentEvent = NSOtherMouseDownMask + | NSOtherMouseUpMask + | NSOtherMouseDraggedMask; + break; + default: + /* Can't happen */ + actionMaskForCurrentEvent = -1; + break; + } + // Prepare the cell tb = [_tableColumns objectAtIndex: _clickedColumn]; cell = [tb dataCellForRow: _clickedRow]; - [cell setObjectValue: [self _objectValueForTableColumn: tb - row: _clickedRow]]; - cellFrame = [self frameOfCellAtColumn: _clickedColumn - row: _clickedRow]; - [cell setHighlighted: YES]; - [self setNeedsDisplayInRect: cellFrame]; - /* give delegate a chance to i.e set target */ - [self _willDisplayCell: cell - forTableColumn: tb - row: _clickedRow]; - if ([cell trackMouse: lastEvent - inRect: cellFrame - ofView: self - untilMouseUp: [[cell class] prefersTrackingUntilMouseUp]]) + if ([cell _sendsActionOn: actionMaskForCurrentEvent]) { - if ([tb isEditable]) - { - [self _setObjectValue: [cell objectValue] - forTableColumn: tb - row: _clickedRow]; - } - done = YES; - currentRow = _clickedRow; - computeNewSelection(self, - oldSelectedRows, - _selectedRows, - originalRow, - oldRow, - currentRow, - &_selectedRow, - selectionMode); + [cell setObjectValue: [self _objectValueForTableColumn: tb + row: _clickedRow]]; + cellFrame = [self frameOfCellAtColumn: _clickedColumn + row: _clickedRow]; + [cell setHighlighted: YES]; + [self setNeedsDisplayInRect: cellFrame]; + /* give delegate a chance to i.e set target */ + [self _willDisplayCell: cell + forTableColumn: tb + row: _clickedRow]; + if ([cell trackMouse: lastEvent + inRect: cellFrame + ofView: self + untilMouseUp: [[cell class] prefersTrackingUntilMouseUp]]) + { + if ([tb isEditable]) + { + [self _setObjectValue: [cell objectValue] + forTableColumn: tb + row: _clickedRow]; + } + done = YES; + currentRow = _clickedRow; + computeNewSelection(self, + oldSelectedRows, + _selectedRows, + originalRow, + oldRow, + currentRow, + &_selectedRow, + selectionMode); + } + + [cell setHighlighted: NO]; + [self setNeedsDisplayInRect: cellFrame]; + lastEvent = [NSApp currentEvent]; } - [cell setHighlighted: NO]; - [self setNeedsDisplayInRect: cellFrame]; - lastEvent = [NSApp currentEvent]; } while (done != YES) diff --git a/Source/NSTextFieldCell.m b/Source/NSTextFieldCell.m index a3e590cb6..200e81b71 100644 --- a/Source/NSTextFieldCell.m +++ b/Source/NSTextFieldCell.m @@ -35,6 +35,7 @@ #include "AppKit/NSGraphics.h" #include "AppKit/NSTextFieldCell.h" #include "AppKit/NSText.h" +#include "AppKit/NSEvent.h" static NSColor *bgCol; static NSColor *txtCol; @@ -94,6 +95,7 @@ static NSColor *txtCol; ASSIGN(_background_color, bgCol); _textfieldcell_draws_background = NO; _textfieldcell_is_opaque = NO; + _action_mask = NSKeyUpMask | NSKeyDownMask; return self; }