mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-04-23 12:00:52 +00:00
Improved mouseDown call handling for table view.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@21262 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
303dd1baf9
commit
eb7eaa1654
2 changed files with 48 additions and 64 deletions
|
@ -1,3 +1,11 @@
|
|||
2005-05-26 Fred Kiefer <FredKiefer@gmx.de>
|
||||
|
||||
* Source/NSTableView.m (-mouseDown): Replaced use of
|
||||
_sendsActionOn: with a check if the value did change
|
||||
after the cell did track the mouse. Also use a copy of the cell,
|
||||
that way other cells are not affected by changes in the tracked
|
||||
cell. Patch based on code by Matt Rice <ratmice@yahoo.com>.
|
||||
|
||||
2005-05-25 Adam Fedor <fedor@gnu.org>
|
||||
|
||||
* Update FSF Address.
|
||||
|
|
|
@ -3100,12 +3100,11 @@ byExtendingSelection: (BOOL)flag
|
|||
if (_textObject)
|
||||
{
|
||||
[_editedCell endEditing: _textObject];
|
||||
RELEASE (_editedCell);
|
||||
DESTROY(_editedCell);
|
||||
[self setNeedsDisplayInRect:
|
||||
[self frameOfCellAtColumn: _editedColumn row: _editedRow]];
|
||||
_editedRow = -1;
|
||||
_editedColumn = -1;
|
||||
_editedCell = nil;
|
||||
_textObject = nil;
|
||||
return YES;
|
||||
}
|
||||
|
@ -3375,7 +3374,7 @@ static inline float computePeriod(NSPoint mouseLocationWin,
|
|||
{
|
||||
// It is OK to edit column. Go on, do it.
|
||||
[self editColumn: _clickedColumn row: _clickedRow
|
||||
withEvent: theEvent select: NO];
|
||||
withEvent: theEvent select: YES];
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -3449,81 +3448,58 @@ static inline float computePeriod(NSPoint mouseLocationWin,
|
|||
|
||||
// let's sort the _selectedRows
|
||||
oldSelectedRows = [_selectedRows copy];
|
||||
|
||||
mouseLocationView = location;
|
||||
lastEvent = theEvent;
|
||||
|
||||
if ([self mouse: mouseLocationView inRect: _bounds])
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
||||
id originalValue;
|
||||
|
||||
// Prepare the cell
|
||||
tb = [_tableColumns objectAtIndex: _clickedColumn];
|
||||
cell = [tb dataCellForRow: _clickedRow];
|
||||
if ([cell _sendsActionOn: actionMaskForCurrentEvent])
|
||||
{
|
||||
[cell setObjectValue: [self _objectValueForTableColumn: tb
|
||||
row: _clickedRow]];
|
||||
cellFrame = [self frameOfCellAtColumn: _clickedColumn
|
||||
cell = [[tb dataCellForRow: _clickedRow] copy];
|
||||
originalValue = RETAIN([self _objectValueForTableColumn:tb row:_clickedRow]);
|
||||
[cell setObjectValue: originalValue];
|
||||
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
|
||||
[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]])
|
||||
untilMouseUp: [[cell class] prefersTrackingUntilMouseUp]])
|
||||
{
|
||||
id newValue = [cell objectValue];
|
||||
|
||||
if ([tb isEditable] && ![originalValue isEqual: newValue])
|
||||
{
|
||||
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];
|
||||
[self _setObjectValue: newValue
|
||||
forTableColumn: tb
|
||||
row: _clickedRow];
|
||||
}
|
||||
done = YES;
|
||||
currentRow = _clickedRow;
|
||||
computeNewSelection(self,
|
||||
oldSelectedRows,
|
||||
_selectedRows,
|
||||
originalRow,
|
||||
oldRow,
|
||||
currentRow,
|
||||
&_selectedRow,
|
||||
selectionMode);
|
||||
}
|
||||
RELEASE(originalValue);
|
||||
[cell setHighlighted: NO];
|
||||
RELEASE(cell);
|
||||
[self setNeedsDisplayInRect: cellFrame];
|
||||
lastEvent = [NSApp currentEvent];
|
||||
}
|
||||
|
||||
while (done != YES)
|
||||
|
|
Loading…
Reference in a new issue