diff --git a/ChangeLog b/ChangeLog index 21be27e97..921d62884 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2011-11-28 Fred Kiefer + + * Source/NSPopUpButtonCell.m (-initWithCoder:): If no selection + index is given select the first item. This should fix bug #34923. + 2011-11-28 Fred Kiefer * Source/NSTextView.m (-buildUpTextNetwork:): Move setting the diff --git a/Source/NSPopUpButtonCell.m b/Source/NSPopUpButtonCell.m index 28aa63188..285abdf3f 100644 --- a/Source/NSPopUpButtonCell.m +++ b/Source/NSPopUpButtonCell.m @@ -204,6 +204,7 @@ static NSImage *_pbc_image[5]; [self setMenuView: nil]; } + // FIXME: Select the first or last item? [self selectItemAtIndex: [_menu numberOfItems] - 1]; [self synchronizeTitleAndSelectedItem]; } @@ -1233,6 +1234,11 @@ static NSImage *_pbc_image[5]; [self setAltersStateOfSelectedItem: alters]; } + if ([aDecoder containsValueForKey: @"NSPullDown"]) + { + BOOL pullDown = [aDecoder decodeBoolForKey: @"NSPullDown"]; + [self setPullsDown: pullDown]; + } if ([aDecoder containsValueForKey: @"NSUsesItemFromMenu"]) { BOOL usesItem = [aDecoder decodeBoolForKey: @"NSUsesItemFromMenu"]; @@ -1256,13 +1262,17 @@ static NSImage *_pbc_image[5]; { int selectedIdx = [aDecoder decodeIntForKey: @"NSSelectedIndex"]; - [self selectItem: [self itemAtIndex: selectedIdx]]; + [self selectItemAtIndex: selectedIdx]; } - if ([aDecoder containsValueForKey: @"NSPullDown"]) + else { - BOOL pullDown = [aDecoder decodeBoolForKey: @"NSPullDown"]; - [self setPullsDown: pullDown]; - } + [self selectItemAtIndex: 0]; + } + if ([aDecoder containsValueForKey: @"NSMenuItem"]) + { + NSMenuItem *item = [aDecoder decodeObjectForKey: @"NSMenuItem"]; + [self setMenuItem: item]; + } } else {