From 034beeffb4490a61d5ba44d803eb4e45a0d2eee4 Mon Sep 17 00:00:00 2001 From: Wolfgang Lux Date: Sun, 15 Aug 2010 20:28:06 +0000 Subject: [PATCH] Fix bug caused by the fix for #30025, which made it impossible to programmatically change the selected item of some pop up buttons. git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@31158 72102866-910b-0410-8b05-ffd578937521 --- ChangeLog | 4 ++++ Source/NSPopUpButtonCell.m | 11 +++++++---- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index cabea3cf9..3a87e3bb4 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,9 @@ 2010-08-15 Wolfgang Lux + * Source/NSPopUpButtonCell.m (-selectItem): Fix bug caused by the + fix for #30025, which made it impossible to programmatically + change the selected item of some pop up buttons. + * Source/NSComboBoxCell.m (-runLoopWithComboBoxCell:): Dismiss the combo box's list without changing the selection when the user presses Escape. diff --git a/Source/NSPopUpButtonCell.m b/Source/NSPopUpButtonCell.m index 206ae6b1b..ee2744c03 100644 --- a/Source/NSPopUpButtonCell.m +++ b/Source/NSPopUpButtonCell.m @@ -661,6 +661,13 @@ static NSImage *_pbc_image[5]; _selectedItem = item; + /* Set the item in the menu */ + /* Note: Must do this before changing the state of the selected item, since + * the change will recursively invoke synchronizeTitleAndSelectedItem, which + * otherwise would select the old item again */ + [[_menu menuRepresentation] setHighlightedItemIndex: + [_menu indexOfItem: _selectedItem]]; + if (_selectedItem != nil) { if (_pbcFlags.altersStateOfSelectedItem) @@ -669,10 +676,6 @@ static NSImage *_pbc_image[5]; } } - /* Set the item in the menu */ - [[_menu menuRepresentation] setHighlightedItemIndex: - [_menu indexOfItem: _selectedItem]]; - if (oldSelectedItem) { [[_menu menuRepresentation] setNeedsDisplayForItemAtIndex: