Avoid writing back an unchanged string to the cell's field editor.

Fix bug where an attributed string would not be considered a valid
object value of a cell.


git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@29059 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Wolfgang Lux 2009-11-24 23:53:58 +00:00
parent 3ebf818958
commit 9ee683802f
2 changed files with 22 additions and 6 deletions

View file

@ -1,5 +1,12 @@
2009-11-25 Wolfgang Lux <wolfgang.lux@gmail.com>
* Source/NSCell.m (-_updateFieldEditor:): Don't write back
unchanged strings to the field editor. Should prevent the editor's
selection from changing when -validateEditing is called.
* Source/NSCell.m (-setAttributedStringValue:): Consider the
attributed string a valid object if the cell has no formatter.
* Source/NSTextField.m (-textDidEndEditing:): Fix bug in
textDidEndEditing:.
Patch by Doug Simons <doug.simons@testplant.com>.

View file

@ -968,11 +968,15 @@ static NSColor *dtxtCol;
/* What about the attributed string ? We are loosing it. */
return;
}
_cell.has_valid_object_value = NO;
}
else
{
_cell.has_valid_object_value = YES;
ASSIGN (_object_value, attribStr);
}
/* In all other cases */
ASSIGN (_contents, attribStr);
_cell.has_valid_object_value = NO;
_cell.contents_is_attributed_string = YES;
}
@ -2866,19 +2870,24 @@ static NSColor *dtxtCol;
{
contents = _contents;
}
[textObject setText: contents];
if (![contents isEqualToString: [textObject string]])
[textObject setText: contents];
}
else
{
if (_cell.contents_is_attributed_string == NO)
{
[textObject setText: _contents];
if (![_contents isEqualToString:[textObject string]])
[textObject setText: _contents];
}
else
{
// FIXME what about attribute changes?
NSRange range = NSMakeRange(0, [[textObject string] length]);
[textObject replaceCharactersInRange: range
withAttributedString: (NSAttributedString *)_contents];
if (![[(NSAttributedString *)_contents string] isEqualToString:
[textObject string]])
[textObject replaceCharactersInRange: range
withAttributedString: (NSAttributedString *)_contents];
}
}
}