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

@ -1,3 +1,13 @@
2007-08-31 Fred Kiefer <FredKiefer@gmx.de>
* Source/NSWindow.m (-makeFirstResponder:): When parameter is nil,
set self as first responder and return YES.
* Source/NSCell.m (-isEntryAcceptable:): Accept empty strings.
* Source/NSTableView.m (-validateEditing): Check if delegate
supports method, before calling it.
* Source/NSTextField.m (-validateEditing): Accept empty strings.
Patches partly by Andreas Höschler <ahoesch@smartsoft.de>.
2007-08-29 Fred Kiefer <FredKiefer@gmx.de>
* Headers/AppKit/NSCell.h: Export more private drawing methods.

View file

@ -1238,13 +1238,13 @@ static NSColor *shadowCol;
- (BOOL) isEntryAcceptable: (NSString*)aString
{
if (_formatter != nil)
if ((_formatter != nil) && ![aString isEqualToString: @""])
{
id newObjectValue;
return [_formatter getObjectValue: &newObjectValue
forString: aString
errorDescription: NULL];
forString: aString
errorDescription: NULL];
}
else
{

View file

@ -3158,50 +3158,64 @@ byExtendingSelection: (BOOL)flag
BOOL validatedOK = YES;
formatter = [_editedCell formatter];
string = AUTORELEASE ([[_textObject text] copy]);
string = AUTORELEASE([[_textObject text] copy]);
if (formatter == nil)
{
newObjectValue = string;
}
{
newObjectValue = string;
}
else
{
NSString *error;
{
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 (_dataSource_editable)
{
NSTableColumn *tb;
tb = [_tableColumns objectAtIndex: _editedColumn];
[self _setObjectValue: newObjectValue
forTableColumn: tb
row: _editedRow];
if ([formatter getObjectValue: &newObjectValue
forString: string
errorDescription: &error] == NO)
{
if ([_delegate respondsToSelector:
@selector(control:didFailToFormatString:errorDescription:)])
{
if ([_delegate control: self
didFailToFormatString: string
errorDescription: error] == NO)
//[_dataSource tableView: self setObjectValue: newObjectValue
// forTableColumn: tb row: _editedRow];
}
}
{
validatedOK = NO;
}
else
{
newObjectValue = string;
}
}
// Allow an empty string to fall through
else if ([string isEqualToString: @""])
{
newObjectValue = string;
}
else
{
validatedOK = NO;
}
}
}
if (validatedOK == YES)
{
[_editedCell setObjectValue: newObjectValue];
if (_dataSource_editable)
{
NSTableColumn *tb;
tb = [_tableColumns objectAtIndex: _editedColumn];
[self _setObjectValue: newObjectValue
forTableColumn: tb
row: _editedRow];
//[_dataSource tableView: self setObjectValue: newObjectValue
// forTableColumn: tb row: _editedRow];
}
}
}
}

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];
}
}
}

View file

@ -1363,19 +1363,19 @@ many times.
_f.is_key = YES;
if ((!_firstResponder) || (_firstResponder == self))
{
if (_initialFirstResponder)
{
[self makeFirstResponder: _initialFirstResponder];
}
}
{
if (_initialFirstResponder)
{
[self makeFirstResponder: _initialFirstResponder];
}
}
[_firstResponder becomeFirstResponder];
if ((_firstResponder != self)
&& [_firstResponder respondsToSelector: @selector(becomeKeyWindow)])
{
[_firstResponder becomeKeyWindow];
}
&& [_firstResponder respondsToSelector: @selector(becomeKeyWindow)])
{
[_firstResponder becomeKeyWindow];
}
[_wv setInputState: GSTitleBarKey];
[GSServerForWindow(self) setinputfocus: _windowNum];
@ -2819,11 +2819,11 @@ resetCursorRectsForView(NSView *theView)
return NO;
_firstResponder = aResponder;
if (![_firstResponder becomeFirstResponder])
if ((aResponder == nil) || ![_firstResponder becomeFirstResponder])
{
_firstResponder = self;
[_firstResponder becomeFirstResponder];
return NO;
return (aResponder == nil);
}
return YES;
@ -3893,20 +3893,20 @@ resetCursorRectsForView(NSView *theView)
if ((theView == nil) && (_initialFirstResponder))
{
if ([_initialFirstResponder acceptsFirstResponder])
theView = _initialFirstResponder;
theView = _initialFirstResponder;
else
theView = [_initialFirstResponder nextValidKeyView];
theView = [_initialFirstResponder nextValidKeyView];
}
if (theView)
{
[self makeFirstResponder: theView];
if ([theView respondsToSelector:@selector(selectText:)])
{
_selectionDirection = NSSelectingNext;
[(id)theView selectText: self];
_selectionDirection = NSDirectSelection;
}
{
_selectionDirection = NSSelectingNext;
[(id)theView selectText: self];
_selectionDirection = NSDirectSelection;
}
}
}
@ -3929,20 +3929,20 @@ resetCursorRectsForView(NSView *theView)
if ((theView == nil) && (_initialFirstResponder))
{
if ([_initialFirstResponder acceptsFirstResponder])
theView = _initialFirstResponder;
theView = _initialFirstResponder;
else
theView = [_initialFirstResponder previousValidKeyView];
theView = [_initialFirstResponder previousValidKeyView];
}
if (theView)
{
[self makeFirstResponder: theView];
if ([theView respondsToSelector:@selector(selectText:)])
{
_selectionDirection = NSSelectingPrevious;
[(id)theView selectText: self];
_selectionDirection = NSDirectSelection;
}
{
_selectionDirection = NSSelectingPrevious;
[(id)theView selectText: self];
_selectionDirection = NSDirectSelection;
}
}
}