Implemented object value/formatter support

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@7284 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Nicola Pero 2000-08-29 18:44:33 +00:00
parent c96a2cd4db
commit a9f4a28379

View file

@ -1087,21 +1087,57 @@ byExtendingSelection: (BOOL)flag
}
- (void) validateEditing
{
{
if (_textObject)
{
[_editedCell setStringValue: [_textObject text]];
NSFormatter *formatter;
NSString *string;
id newObjectValue;
BOOL validatedOK = YES;
if (_del_editable)
formatter = [_editedCell formatter];
string = [_textObject text];
if (formatter == nil)
{
[_delegate tableView: self
setObjectValue: [_editedCell objectValue]
forTableColumn: [_tableColumns objectAtIndex:
_editedColumn]
row: _editedRow];
newObjectValue = string;
}
else
{
NSString *error;
if ([formatter getObjectValue: &newObjectValue
forString: string
errorDescription: &error] == NO)
{
if ([_delegate control: self
didFailToFormatString: string
errorDescription: error] == NO)
{
validatedOK = NO;
}
else
{
newObjectValue = string;
}
}
}
if (validatedOK == YES)
{
[_editedCell setObjectValue: newObjectValue];
if (_del_editable)
{
NSTableColumn *tb;
tb = [_tableColumns objectAtIndex: _editedColumn];
[_delegate tableView: self setObjectValue: newObjectValue
forTableColumn: tb row: _editedRow];
}
}
}
}
}
- (void) editColumn: (int) columnIndex
row: (int) rowIndex
@ -1586,8 +1622,13 @@ byExtendingSelection: (BOOL)flag
}
}
}
// Double-click events
// FIXME: Start editing only if row is selected
if ([self isRowSelected: _clickedRow] == NO)
return;
if ([_delegate respondsToSelector:
@selector(tableView:shouldEditTableColumn:row:)])
{
@ -2411,6 +2452,24 @@ byExtendingSelection: (BOOL)flag
return YES;
}
if ([_delegate respondsToSelector:
@selector(control:isValidObject:)] == YES)
{
NSFormatter *formatter;
id newObjectValue;
formatter = [_cell formatter];
if ([formatter getObjectValue: &newObjectValue
forString: [_textObject text]
errorDescription: NULL] == YES)
{
if ([_delegate control: self
isValidObject: newObjectValue] == NO)
return NO;
}
}
return [_editedCell isEntryAcceptable: [aTextObject text]];
}