mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-05-31 20:10:47 +00:00
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:
parent
b154c6cf05
commit
29cc05dc4a
1 changed files with 69 additions and 10 deletions
|
@ -1087,21 +1087,57 @@ byExtendingSelection: (BOOL)flag
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) validateEditing
|
- (void) validateEditing
|
||||||
{
|
{
|
||||||
if (_textObject)
|
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
|
newObjectValue = string;
|
||||||
setObjectValue: [_editedCell objectValue]
|
}
|
||||||
forTableColumn: [_tableColumns objectAtIndex:
|
else
|
||||||
_editedColumn]
|
{
|
||||||
row: _editedRow];
|
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
|
- (void) editColumn: (int) columnIndex
|
||||||
row: (int) rowIndex
|
row: (int) rowIndex
|
||||||
|
@ -1586,8 +1622,13 @@ byExtendingSelection: (BOOL)flag
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Double-click events
|
// Double-click events
|
||||||
|
|
||||||
|
// FIXME: Start editing only if row is selected
|
||||||
|
if ([self isRowSelected: _clickedRow] == NO)
|
||||||
|
return;
|
||||||
|
|
||||||
if ([_delegate respondsToSelector:
|
if ([_delegate respondsToSelector:
|
||||||
@selector(tableView:shouldEditTableColumn:row:)])
|
@selector(tableView:shouldEditTableColumn:row:)])
|
||||||
{
|
{
|
||||||
|
@ -2411,6 +2452,24 @@ byExtendingSelection: (BOOL)flag
|
||||||
return YES;
|
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]];
|
return [_editedCell isEntryAcceptable: [aTextObject text]];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue