From ca26a5ce28aea34e1e4115b1dacba4e73c9ebc09 Mon Sep 17 00:00:00 2001 From: Sergii Stoian Date: Fri, 11 Apr 2003 10:35:36 +0000 Subject: [PATCH] mouseDown fix git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@16427 72102866-910b-0410-8b05-ffd578937521 --- Source/NSPopUpButton.m | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/Source/NSPopUpButton.m b/Source/NSPopUpButton.m index 410a01e29..f66cbebb5 100644 --- a/Source/NSPopUpButton.m +++ b/Source/NSPopUpButton.m @@ -340,7 +340,7 @@ this to return nil to indicate that we have no context menu. // Attach the popUp [_cell attachPopUpWithFrame: _bounds - inView: self]; + inView: self]; p = [_window convertBaseToScreen: [theEvent locationInWindow]]; p = [menuWindow convertScreenToBase: p]; @@ -358,12 +358,18 @@ this to return nil to indicate that we have no context menu. pressure: [theEvent pressure]]; [NSApp sendEvent: e]; - // Selection remains unchanged if selected item is disabled - // or mouse left menu. + // Get highlighted item index from _cell because NSMenuView: + // - tells to NSPopUpButtonCell about current selected item index; + // - sets own selected item index to -1; + // + // So, at this point [mr highlightedItemIndex] always = -1 highlightedItemIndex = [_cell indexOfSelectedItem]; - if ((highlightedItemIndex >= 0 - && [[self itemAtIndex: highlightedItemIndex] isEnabled] == NO) - || highlightedItemIndex == lastSelectedItem) + + // Selection remains unchanged if selected item is disabled + // or mouse left menu (highlightedItemIndex == -1). + if ( highlightedItemIndex < 0 + || highlightedItemIndex == lastSelectedItem + || [[self itemAtIndex: highlightedItemIndex] isEnabled] == NO) { [mr setHighlightedItemIndex: lastSelectedItem]; }