Made selecting values from a combo box in a table view work.

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@19568 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Fred Kiefer 2004-06-20 22:25:17 +00:00
parent 58a073e7c5
commit 130440495b
3 changed files with 78 additions and 22 deletions

View file

@ -1,3 +1,11 @@
2004-06-20 Fred Kiefer <FredKiefer@gmx.de>
* Source/NSTableView.m: (-mouseDown:) Set value after cell tracking.
(_setObjectValue:forTableColumn:row:) Check for correct method.
Patch by Matt Rice <ratmice@yahoo.com>
* Source/NSComboBoxCell.m: (-objectValue) Added this method, as
the object value never gets set.
2004-06-19 Fred Kiefer <FredKiefer@gmx.de>
* Source/GSDragView.m: (-_handleEventDuringDragging:) Get mouse

View file

@ -1167,6 +1167,48 @@ numberOfRowsInColumn: (int)column
}
}
/* FIXME: Not sure, if this is the best way to implement objectValue,
* perhaps it would be better to store the current value with setObjectValue:
* whenever it changes.
*/
- (id) objectValue
{
int index = [self indexOfSelectedItem];
if (index == -1)
{
return nil;
}
else
{
if (_usesDataSource)
{
if (!_dataSource)
{
NSLog(@"%@: No data source currently specified", self);
return nil;
}
if ([_dataSource respondsToSelector:
@selector(comboBox:objectValueForItemAtIndex:)])
{
return [_dataSource comboBox: (NSComboBox *)[self controlView]
objectValueForItemAtIndex: index];
}
else if ([_dataSource respondsToSelector:
@selector(comboBoxCell:objectValueForItemAtIndex:)])
{
return [_dataSource comboBoxCell: self
objectValueForItemAtIndex: index];
}
}
else
{
return [self itemObjectValueAtIndex: index];
}
}
return nil;
}
/**
* Returns the object value of the selected item in the combo box cell default
* items list or nil when there is no selection. In the case

View file

@ -3455,31 +3455,40 @@ inline float computePeriod(NSPoint mouseLocationWin,
{
NSTableColumn *tb;
NSCell *cell;
NSRect rect;
int columnIndex;
int rowIndex;
NSRect cellFrame;
rowIndex = [self rowAtPoint: mouseLocationView];
columnIndex = [self columnAtPoint: mouseLocationView];
// Prepare the cell
tb = [_tableColumns objectAtIndex: columnIndex];
tb = [_tableColumns objectAtIndex: _clickedColumn];
// NB: need to be released when no longer used
cell = [[tb dataCellForRow: rowIndex] copy];
[cell setEditable: YES];
// Not sure if we really need a copy here.
cell = [[tb dataCellForRow: _clickedRow] copy];
[cell setObjectValue: [self _objectValueForTableColumn: tb
row: rowIndex]];
rect = [self frameOfCellAtColumn: columnIndex
row: rowIndex];
row: _clickedRow]];
cellFrame = [self frameOfCellAtColumn: _clickedColumn
row: _clickedRow];
[cell setHighlighted: YES];
[self setNeedsDisplayInRect: rect];
[self setNeedsDisplayInRect: cellFrame];
/* give delegate a chance to i.e set target */
if (_del_responds)
{
[_delegate tableView: self
willDisplayCell: cell
forTableColumn: tb
row: _clickedRow];
}
if ([cell trackMouse: lastEvent
inRect: rect
inRect: cellFrame
ofView: self
untilMouseUp: [[cell class] prefersTrackingUntilMouseUp]])
{
if ([tb isEditable])
{
[self _setObjectValue: [cell objectValue]
forTableColumn: tb
row: _clickedRow];
}
done = YES;
currentRow = rowIndex;
currentRow = _clickedRow;
computeNewSelection(self,
oldSelectedRows,
_selectedRows,
@ -3488,13 +3497,10 @@ inline float computePeriod(NSPoint mouseLocationWin,
currentRow,
&_selectedRow,
selectionMode);
[self displayIfNeeded];
}
else
{
[cell setHighlighted: NO];
[self setNeedsDisplayInRect: rect];
}
[cell setHighlighted: NO];
[self setNeedsDisplayInRect: cellFrame];
lastEvent = [NSApp currentEvent];
DESTROY(cell);
}
@ -5881,7 +5887,7 @@ inline float computePeriod(NSPoint mouseLocationWin,
row: (int) index
{
if([_dataSource respondsToSelector:
@selector(tableView:objectValueForTableColumn:row:)])
@selector(tableView:setObjectValue:forTableColumn:row:)])
{
[_dataSource tableView: self
setObjectValue: value