mirror of
https://github.com/fltk/fltk.git
synced 2026-06-06 08:32:07 +08:00
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
This commit is contained in:
+15
-4
@@ -3525,10 +3525,17 @@ int Fl_X::set_cursor(const Fl_RGB_Image *image, int hotx, int hoty) {
|
|||||||
@interface FLaboutItemTarget : NSObject
|
@interface FLaboutItemTarget : NSObject
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
- (BOOL)validateMenuItem:(NSMenuItem *)item;
|
||||||
- (void)showPanel;
|
- (void)showPanel;
|
||||||
- (void)printPanel;
|
- (void)printPanel;
|
||||||
|
- (void)terminate:(id)sender;
|
||||||
@end
|
@end
|
||||||
@implementation FLaboutItemTarget
|
@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
|
- (void)showPanel
|
||||||
{
|
{
|
||||||
NSDictionary *options;
|
NSDictionary *options;
|
||||||
@@ -3576,6 +3583,10 @@ int Fl_X::set_cursor(const Fl_RGB_Image *image, int hotx, int hoty) {
|
|||||||
printer.end_job();
|
printer.end_job();
|
||||||
fl_unlock_function();
|
fl_unlock_function();
|
||||||
}
|
}
|
||||||
|
- (void)terminate:(id)sender
|
||||||
|
{
|
||||||
|
[NSApp terminate:sender];
|
||||||
|
}
|
||||||
@end
|
@end
|
||||||
|
|
||||||
static void createAppleMenu(void)
|
static void createAppleMenu(void)
|
||||||
@@ -3606,7 +3617,6 @@ static void createAppleMenu(void)
|
|||||||
action:@selector(printPanel)
|
action:@selector(printPanel)
|
||||||
keyEquivalent:@""];
|
keyEquivalent:@""];
|
||||||
[menuItem setTarget:about];
|
[menuItem setTarget:about];
|
||||||
[appleMenu setAutoenablesItems:NO];
|
|
||||||
[menuItem setEnabled:YES];
|
[menuItem setEnabled:YES];
|
||||||
[appleMenu addItem:[NSMenuItem separatorItem]];
|
[appleMenu addItem:[NSMenuItem separatorItem]];
|
||||||
}
|
}
|
||||||
@@ -3637,9 +3647,10 @@ static void createAppleMenu(void)
|
|||||||
// Quit AppName
|
// Quit AppName
|
||||||
title = [NSString stringWithFormat:NSLocalizedString([NSString stringWithUTF8String:Fl_Mac_App_Menu::quit] , nil),
|
title = [NSString stringWithFormat:NSLocalizedString([NSString stringWithUTF8String:Fl_Mac_App_Menu::quit] , nil),
|
||||||
nsappname];
|
nsappname];
|
||||||
[appleMenu addItemWithTitle:title
|
menuItem = [appleMenu addItemWithTitle:title
|
||||||
action:@selector(terminate:)
|
action:@selector(terminate:)
|
||||||
keyEquivalent:@"q"];
|
keyEquivalent:@"q"];
|
||||||
|
[menuItem setTarget:about];
|
||||||
}
|
}
|
||||||
/* Put menu into the menubar */
|
/* Put menu into the menubar */
|
||||||
menuItem = [[NSMenuItem alloc] initWithTitle:@"" action:nil keyEquivalent:@""];
|
menuItem = [[NSMenuItem alloc] initWithTitle:@"" action:nil keyEquivalent:@""];
|
||||||
|
|||||||
Reference in New Issue
Block a user