From ae51e23b362b715fb815a11e8541cb01c34201bb Mon Sep 17 00:00:00 2001 From: dpsimons Date: Mon, 30 Aug 2010 23:02:21 +0000 Subject: [PATCH] fix problem of pulldown action not being called for correct cell, and being called twice on Windows git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@31213 72102866-910b-0410-8b05-ffd578937521 --- ChangeLog | 8 ++++++++ Source/NSMenuView.m | 9 +++++++++ Source/NSPopUpButtonCell.m | 4 ++++ 3 files changed, 21 insertions(+) diff --git a/ChangeLog b/ChangeLog index 6161486f0..4cfc0bc31 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2010-08-30 Doug Simons + + * Source/NSPopUpButtonCell.m: + Fix problem of pulldown action not being called with correct cell + selected (possibly only a problem for Mac nib files?). + * Source/NSMenuView.m: + Fix problem of pulldown action getting invoked twice on Windows. + 2010-08-30 Wolfgang Lux * Source/NSTableView.m (computeNewSelection): Fix bug where the diff --git a/Source/NSMenuView.m b/Source/NSMenuView.m index 48837256a..2f78906ec 100644 --- a/Source/NSMenuView.m +++ b/Source/NSMenuView.m @@ -1452,6 +1452,13 @@ static NSMapTable *viewInfo = 0; NSEvent *original; NSEventType type; NSEventType end; + NSPopUpButtonCell *bcell = nil; + SEL bcellAction = NULL; + if([_attachedMenu _ownedByPopUp]) + { + bcell = [_attachedMenu _owningPopUp]; + bcellAction = [bcell action]; + } /* * The original event is unused except to determine whether the method @@ -1656,11 +1663,13 @@ static NSMapTable *viewInfo = 0; lastLocation = location; } + [bcell setAction:NULL]; // block actions while fetching an event (this is a problem on Windows) event = [NSApp nextEventMatchingMask: eventMask untilDate: theDistantFuture inMode: NSEventTrackingRunLoopMode dequeue: YES]; type = [event type]; + [bcell setAction:bcellAction]; // restore the popUpButtonCell's action } while (type != end || shouldFinish == NO); diff --git a/Source/NSPopUpButtonCell.m b/Source/NSPopUpButtonCell.m index ee2744c03..36204c896 100644 --- a/Source/NSPopUpButtonCell.m +++ b/Source/NSPopUpButtonCell.m @@ -1304,6 +1304,10 @@ static NSImage *_pbc_image[5]; */ - (void) _popUpItemAction: (id)sender { + // first, if sender is one of our items, set it as our selected item + int index = [_menu indexOfItem:sender]; + if (index != NSNotFound) + [self selectItemAtIndex:index]; [NSApp sendAction: [self action] to: [self target] from: self]; }