Editing patches partly by Andreas Höschler <ahoesch@smartsoft.de>.

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@25426 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
fredkiefer 2007-08-31 10:52:52 +00:00
parent 561e8d0985
commit ddb1df7caa
5 changed files with 140 additions and 111 deletions

View file

@ -376,22 +376,22 @@ static Class textFieldCellClass;
* was in use by another control.
*/
if ([_window makeFirstResponder: self])
{
NSText *t = [_window fieldEditor: YES forObject: self];
{
NSText *t = [_window fieldEditor: YES forObject: self];
if ([t superview] != nil)
{
/* Can't take the field editor ... give up. */
return;
}
_text_object = [_cell setUpFieldEditorAttributes: t];
[_cell editWithFrame: _bounds
inView: self
editor: _text_object
delegate: self
event: theEvent];
}
if ([t superview] != nil)
{
/* Can't take the field editor ... give up. */
return;
}
_text_object = [_cell setUpFieldEditorAttributes: t];
[_cell editWithFrame: _bounds
inView: self
editor: _text_object
delegate: self
event: theEvent];
}
}
}
@ -457,39 +457,44 @@ static Class textFieldCellClass;
{
NSFormatter *formatter;
NSString *string;
BOOL validatedOK = YES;
formatter = [_cell formatter];
string = AUTORELEASE ([[_text_object text] copy]);
if (formatter == nil)
{
[_cell setStringValue: string];
}
else
{
id newObjectValue;
NSString *error;
if ([formatter getObjectValue: &newObjectValue
forString: string
errorDescription: &error] == YES)
{
[_cell setObjectValue: newObjectValue];
}
else
{
SEL sel = @selector(control:didFailToFormatString:errorDescription:);
if (formatter != nil)
{
id newObjectValue;
NSString *error;
if ([formatter getObjectValue: &newObjectValue
forString: string
errorDescription: &error] == YES)
{
[_cell setObjectValue: newObjectValue];
return;
}
else
{
SEL sel = @selector(control:didFailToFormatString:errorDescription:);
if ([_delegate respondsToSelector: sel])
{
validatedOK = [_delegate control: self
didFailToFormatString: string
errorDescription: error];
}
else if (![string isEqualToString: @""])
{
validatedOK = NO;
}
}
}
if ([_delegate respondsToSelector: sel] &&
[_delegate control: self
didFailToFormatString: string
errorDescription: error] == YES)
{
[_cell setStringValue: string];
}
}
}
if (validatedOK)
{
[_cell setStringValue: string];
}
}
}