diff options
| author | Manolo Gouy <Manolo> | 2014-11-15 14:55:15 +0000 |
|---|---|---|
| committer | Manolo Gouy <Manolo> | 2014-11-15 14:55:15 +0000 |
| commit | cc9b73d97a9aeca522d08e0e4dfcac757dcc0e3d (patch) | |
| tree | 3d0651e059e077f94d83292f66481811dd3c819e /src | |
| parent | 43989ec606db056c82d113ad998ae285b5d4f8c4 (diff) | |
Invalidate the Quit item of the application menu when running modal.
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@10455 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
Diffstat (limited to 'src')
| -rw-r--r-- | src/Fl_cocoa.mm | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/src/Fl_cocoa.mm b/src/Fl_cocoa.mm index be236011e..e2bf97c46 100644 --- a/src/Fl_cocoa.mm +++ b/src/Fl_cocoa.mm @@ -3525,10 +3525,17 @@ int Fl_X::set_cursor(const Fl_RGB_Image *image, int hotx, int hoty) { @interface FLaboutItemTarget : NSObject { } +- (BOOL)validateMenuItem:(NSMenuItem *)item; - (void)showPanel; - (void)printPanel; +- (void)terminate:(id)sender; @end @implementation FLaboutItemTarget +- (BOOL)validateMenuItem:(NSMenuItem *)item +{ // invalidate the Quit item of the application menu when running modal + if (!Fl::modal() || [item action] != @selector(terminate:)) return YES; + return NO; +} - (void)showPanel { NSDictionary *options; @@ -3576,6 +3583,10 @@ int Fl_X::set_cursor(const Fl_RGB_Image *image, int hotx, int hoty) { printer.end_job(); fl_unlock_function(); } +- (void)terminate:(id)sender +{ + [NSApp terminate:sender]; +} @end static void createAppleMenu(void) @@ -3606,7 +3617,6 @@ static void createAppleMenu(void) action:@selector(printPanel) keyEquivalent:@""]; [menuItem setTarget:about]; - [appleMenu setAutoenablesItems:NO]; [menuItem setEnabled:YES]; [appleMenu addItem:[NSMenuItem separatorItem]]; } @@ -3637,9 +3647,10 @@ static void createAppleMenu(void) // Quit AppName title = [NSString stringWithFormat:NSLocalizedString([NSString stringWithUTF8String:Fl_Mac_App_Menu::quit] , nil), nsappname]; - [appleMenu addItemWithTitle:title - action:@selector(terminate:) - keyEquivalent:@"q"]; + menuItem = [appleMenu addItemWithTitle:title + action:@selector(terminate:) + keyEquivalent:@"q"]; + [menuItem setTarget:about]; } /* Put menu into the menubar */ menuItem = [[NSMenuItem alloc] initWithTitle:@"" action:nil keyEquivalent:@""]; |
