From 5efe558c2b4b27109c859f8f3e51f08becb09244 Mon Sep 17 00:00:00 2001 From: gcasa Date: Mon, 16 Feb 2009 00:31:23 +0000 Subject: [PATCH] * Source/NSCell.m: Change to implement 10.3 and later behavior for the method setStringValue: as documented in Apple's documentation for the method. This behavior was observed on Cocoa under Mac OS 10.5. git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@27874 72102866-910b-0410-8b05-ffd578937521 --- ChangeLog | 7 +++++++ Source/NSCell.m | 37 +++++++++++++++++++++++++++++++++---- 2 files changed, 40 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index 90ddd105e..5793bd0ad 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2009-02-15 19:38-EST Gregory John Casamento + + * Source/NSCell.m: Change to implement 10.3 and later behavior for + the method setStringValue: as documented in Apple's documentation + for the method. This behavior was observed on Cocoa under + Mac OS 10.5. + 2009-02-12 Riccardo Mottola * Source/NSSavePanel.m: Return autoreleased copy of the directory diff --git a/Source/NSCell.m b/Source/NSCell.m index 7669f7750..0a512b379 100644 --- a/Source/NSCell.m +++ b/Source/NSCell.m @@ -329,10 +329,23 @@ static NSColor *dtxtCol; } else { - newContents = [_object_value description]; - _cell.contents_is_attributed_string = NO; - _cell.has_valid_object_value = YES; - } + /// + // If the thing that was assigned is not a string, but + // responds to stringValue then get that. + /// + if([_object_value respondsToSelector: @selector(attributedStringValue)]) + { + newContents = [_object_value attributedStringValue]; + } + else if([_object_value respondsToSelector: @selector(stringValue)]) + { + newContents = [_object_value stringValue]; + } + + newContents = [_object_value description]; + _cell.contents_is_attributed_string = NO; + _cell.has_valid_object_value = YES; + } } else { @@ -420,6 +433,22 @@ static NSColor *dtxtCol; if (_formatter == nil) { + if([string isKindOfClass: [NSString class]] == NO) + { + /// + // If the thing that was assigned is not a string, but + // responds to stringValue then get that. + /// + if([string respondsToSelector: @selector(attributedStringValue)]) + { + string = (NSString *)[(id)string attributedStringValue]; + } + else if([string respondsToSelector: @selector(stringValue)]) + { + string = (NSString *)[(id)string stringValue]; + } + } + ASSIGN (_contents, string); ASSIGN (_object_value, string); _cell.has_valid_object_value = YES;