Fixed the title lost which occurs on switching a button cell to NSNoImage image position (partial fix for #15112)

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@22419 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Quentin Mathe 2006-02-03 12:07:16 +00:00
parent f1d23bd099
commit 89ae500738
2 changed files with 29 additions and 1 deletions

View file

@ -1,3 +1,10 @@
2006-02-03 Quentin Mathe <qmathe@club-internet.fr>
* Source/NSButtonCell.m (-setImagePosition:): Fixed the title lost (reset to
the default one) which was wrongly occuring when the image position is
switched to 'NSNoImage' (partial fix for bug #15112, based on an NSCell
patch by Wolfgang Sourdeau).
2006-02-03 Richard Frith-Macdonald <rfm@gnu.org>
* Source/NSWorkspace.m: In GSLaunched() be more defensive and don't

View file

@ -426,7 +426,28 @@
if (_cell.image_position == NSNoImage)
{
[super setType: NSTextCellType];
/* NOTE: If we always call -setType: on superclass, the cell _content will
be reset each time. When we alter a button displaying both an image and
a title, by just calling -setImagePosition: with 'NSNoImage' value,
the current title is reset to NSCell default one. That's why we have to
set cell type ourself when a custom title (or attributed title) is
already in use.
Take note that [self title] is able to return the attributed title in
NSString form.
We precisely match Mac OS X behavior currently. That means... When you
switch from 'NSNoImage' option to another one, the title will be the
one in use before you switched to 'NSNoImage'. The reverse with the
image isn't true, when you switch to 'NSNoImage' option, the current
image is lost (image value being reset to nil).
*/
if ([self title] == nil || [[self title] isEqualToString: @""])
{
[super setType: NSTextCellType];
}
else
{
_cell.type = NSTextCellType;
}
}
else
{