diff --git a/ChangeLog b/ChangeLog index c51cfd1c..392994b6 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2004-08-05 01:36 Gregory John Casamento + + * Palettes/GormNSMenu.m: Added code in the initWithCoder: + method to subscribe to the notification which indicates + a selection change. When the notification is recieved, + if the menu is owned by a popup the menu is closed. This + corrects Bug#9771. + 2004-08-04 01:08 Gregory John Casamento * GormPalettesManager.m: -[GormPalettesManager loadPalette:] diff --git a/Palettes/0Menus/GormNSMenu.m b/Palettes/0Menus/GormNSMenu.m index b0b554a0..d4136e92 100644 --- a/Palettes/0Menus/GormNSMenu.m +++ b/Palettes/0Menus/GormNSMenu.m @@ -25,22 +25,9 @@ #include "GormNSMenu.h" #include #include - -@interface NSMenu (GormNSMenuPrivate) -- (NSPopUpButtonCell *)popUpButtonCell; -@end - -@implementation NSMenu (GormNSMenuPrivate) -- (NSPopUpButtonCell *)popUpButtonCell -{ - return _popUpButtonCell; -} -@end +#include @interface GormNSMenuWindow : NSPanel -{ - BOOL opened; -} @end @implementation GormNSMenuWindow @@ -67,26 +54,6 @@ NSModalPanelRunLoopMode, NSEventTrackingRunLoopMode, nil]]; - opened = NO; - } -} - -- (void)becomeMainWindow -{ - [super becomeMainWindow]; - if ( [[self menu] _ownedByPopUp] ) - { - /* - if(opened == YES) - { - [[self menu] close]; - opened = NO; - } - else - { - opened = YES; - } - */ } } @@ -113,6 +80,33 @@ @end @implementation GormNSMenu +- (id) initWithCoder: (NSCoder *)coder +{ + if((self = [super initWithCoder: coder]) != nil) + { + NSNotificationCenter *nc = [NSNotificationCenter defaultCenter]; + [nc addObserver: self + selector: @selector(handleNotification:) + name: IBSelectionChangedNotification + object: nil]; + } + + return self; +} + +- (void) handleNotification: (NSNotification *)notification +{ + id object = [notification object]; + if(object != nil) + { + id edited = [object editedObject]; + if(self != edited && [self _ownedByPopUp]) + { + [self close]; + } + } +} + - (BOOL) performKeyEquivalent: (NSEvent*)theEvent { return NO; @@ -159,14 +153,17 @@ NSLog(@"Being released... %d: %@", [self retainCount], self); [super release]; } +*/ +#endif - (void) dealloc { - NSLog(@"Deallocing %@",self); + [[NSNotificationCenter defaultCenter] removeObserver: self + name: IBSelectionChangedNotification + object: nil]; [super dealloc]; } -*/ -#endif + @end @implementation NSMenu (GormNSMenu)