diff --git a/ChangeLog b/ChangeLog index 0f967fca9..00932b410 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2013-09-24 German Arias + + * Source/GSThemeMenu.m (-displayPopUpMenu:withCellFrame:...): If the + PopUp (pulldown) is currently displayed and the theme process events, + allow user close it by clicking over the PopUp button. + 2013-09-23 Ivan Vucica * Source/NSImage.m: Missing -retain inside the method diff --git a/Source/GSThemeMenu.m b/Source/GSThemeMenu.m index 9455f9c94..4af9e95c0 100644 --- a/Source/GSThemeMenu.m +++ b/Source/GSThemeMenu.m @@ -30,6 +30,7 @@ #import #import "AppKit/NSMenu.h" #import "AppKit/NSPanel.h" +#import "AppKit/NSPopUpButtonCell.h" #import "AppKit/NSWindow.h" #import "AppKit/NSMenuView.h" #import "AppKit/NSApplication.h" @@ -40,11 +41,22 @@ #import "NSToolbarFrameworkPrivate.h" #import "GSGuiPrivate.h" +@interface NSMenu (PopUp) +- (NSPopUpButtonCell *)owningPopUp; +@end + @interface NSWindow (Private) - (GSWindowDecorationView *) windowView; - (void) _setMenu: (NSMenu *)menu; @end +@implementation NSMenu (PopUp) +- (NSPopUpButtonCell *)owningPopUp +{ + return _popUpButtonCell; +} +@end + @implementation NSWindow (Private) - (GSWindowDecorationView *) windowView { @@ -104,22 +116,33 @@ controlViewWindow: (NSWindow *)cvWin preferredEdge: (NSRectEdge)edge selectedItem: (int)selectedItem -{ +{ + BOOL pe = [[GSTheme theme] doesProcessEventsForPopUpMenu]; + /* Ensure the window responds when run in modal and should * process events. Or revert this if theme has changed. */ - if ([[GSTheme theme] doesProcessEventsForPopUpMenu] && - ![[mr window] worksWhenModal]) + if (pe && ![[mr window] worksWhenModal]) { [(NSPanel *)[mr window] setWorksWhenModal: YES]; } - if (![[GSTheme theme] doesProcessEventsForPopUpMenu] && - [[mr window] worksWhenModal]) + if (!pe && [[mr window] worksWhenModal]) { [(NSPanel *)[mr window] setWorksWhenModal: NO]; } + /* This is for pulldown PopUp when the theme process events. + * If the popup is currently displayed, close it. If not, the + * user only can close it choosing one option at menu. + */ + if (pe && [[mr window] isVisible] && + [[mr menu] owningPopUp] != nil) + { + [[[mr menu] owningPopUp] dismissPopUp]; + return; + } + // Ask the MenuView to attach the menu to this rect [mr setWindowFrameForAttachingToRect: cellFrame onScreen: [cvWin screen]