From 054851fa01e865efd90a2dffe36b230ee4631808 Mon Sep 17 00:00:00 2001 From: espectador Date: Fri, 27 Sep 2013 07:47:01 +0000 Subject: [PATCH] Close popup if user press a modifier flag an theme process events. git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@37158 72102866-910b-0410-8b05-ffd578937521 --- ChangeLog | 6 ++++++ Source/NSMenuView.m | 32 ++++++++++++++++++++++---------- 2 files changed, 28 insertions(+), 10 deletions(-) diff --git a/ChangeLog b/ChangeLog index 9ba03ddd9..8a2068ff6 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2013-09-27 German Arias + + * Source/NSMenuView.m (- _trackWithEvent:startingMenuView:): If menu + is owned by a popup and theme process events, close it if user press + a modifier key. + 2013-09-26 German Arias * Source/GSThemeMenu.m (-displayPopUpMenu:withCellFrame:...): Revert diff --git a/Source/NSMenuView.m b/Source/NSMenuView.m index f5fb54a61..ff6356258 100644 --- a/Source/NSMenuView.m +++ b/Source/NSMenuView.m @@ -1451,6 +1451,7 @@ static NSMapTable *viewInfo = 0; BOOL justAttachedNewSubmenu = NO; BOOL subMenusNeedRemoving = YES; BOOL shouldFinish = YES; + BOOL popUpProcessEvents = [[GSTheme theme] doesProcessEventsForPopUpMenu]; int delayCount = 0; int indexOfActionToExecute = -1; int firstIndex = -1; @@ -1496,9 +1497,10 @@ static NSMapTable *viewInfo = 0; eventMask |= NSLeftMouseUpMask | NSLeftMouseDraggedMask; eventMask |= NSLeftMouseDownMask; - /*We need know if the user press a modifier key to close the menu - when the menu is in a window*/ - if (style == NSWindows95InterfaceStyle) + /* We need know if the user press a modifier key to close the menu + when the menu is in a window or when is owned by a popup and theme + process events. */ + if (style == NSWindows95InterfaceStyle || popUpProcessEvents) { eventMask |= NSFlagsChangedMask; } @@ -1513,7 +1515,7 @@ static NSMapTable *viewInfo = 0; the other hand, when the user clicks on the button and then moves the mouse the menu is closed upon the next mouse click. */ ([[self menu] _ownedByPopUp] && (style == NSMacintoshInterfaceStyle || - [[GSTheme theme] doesProcessEventsForPopUpMenu]))) + popUpProcessEvents))) { /* * Ignore the first mouse up if nothing interesting has happened. @@ -1522,13 +1524,23 @@ static NSMapTable *viewInfo = 0; } do { - /* Close the menu if the user press a modifier key and menu - is in a window */ - if (mainWindowMenuView != nil && type == NSFlagsChanged) + if (type == NSFlagsChanged) { - [self setHighlightedItemIndex: -1]; - [[[mainWindowMenuView menu] attachedMenu] close]; - return NO; + /* Close the menu if the user press a modifier key and menu + is in a window */ + if (mainWindowMenuView != nil) + { + [self setHighlightedItemIndex: -1]; + [[[mainWindowMenuView menu] attachedMenu] close]; + return NO; + } + + /* Close the menu if is owned by a popup and theme process events */ + if ([[self menu] _ownedByPopUp] && popUpProcessEvents) + { + [[[self menu] _owningPopUp] dismissPopUp]; + return NO; + } } if (type == NSLeftMouseUp ||