cocoa: Fix unresponsive menubar, add default item for application menu.
Closes #259
This commit is contained in:
parent
7062da944a
commit
7830aab21d
|
|
@ -30,6 +30,7 @@
|
|||
|
||||
#import "cocoaPandaView.h"
|
||||
#import "cocoaPandaWindow.h"
|
||||
#import "cocoaPandaAppDelegate.h"
|
||||
|
||||
#import <ApplicationServices/ApplicationServices.h>
|
||||
#import <Foundation/NSAutoreleasePool.h>
|
||||
|
|
@ -71,11 +72,31 @@ CocoaGraphicsWindow(GraphicsEngine *engine, GraphicsPipe *pipe,
|
|||
if (NSApp == nil) {
|
||||
[CocoaPandaApp sharedApplication];
|
||||
|
||||
CocoaPandaAppDelegate *delegate = [[CocoaPandaAppDelegate alloc] init];
|
||||
[NSApp setDelegate:delegate];
|
||||
|
||||
#if __MAC_OS_X_VERSION_MAX_ALLOWED >= 1060
|
||||
[NSApp setActivationPolicy:NSApplicationActivationPolicyRegular];
|
||||
#endif
|
||||
NSMenu *mainMenu = [[NSMenu alloc] init];
|
||||
|
||||
NSMenuItem *applicationMenuItem = [[NSMenuItem alloc] init];
|
||||
[mainMenu addItem:applicationMenuItem];
|
||||
|
||||
NSMenu *applicationMenu = [[NSMenu alloc] init];
|
||||
|
||||
NSMenuItem *item = [[NSMenuItem alloc] init];
|
||||
item.action = @selector(terminate:);
|
||||
item.keyEquivalent = @"q";
|
||||
|
||||
NSString *appName = [NSRunningApplication currentApplication].localizedName;
|
||||
item.title = [NSString stringWithFormat:@"Quit %@", appName];
|
||||
|
||||
[applicationMenu addItem:item];
|
||||
|
||||
[mainMenu setSubmenu:applicationMenu forItem:applicationMenuItem];
|
||||
[NSApp setMainMenu:mainMenu];
|
||||
[NSApp finishLaunching];
|
||||
[NSApp activateIgnoringOtherApps:YES];
|
||||
}
|
||||
|
||||
GraphicsWindowInputDevice device =
|
||||
|
|
|
|||
|
|
@ -0,0 +1,22 @@
|
|||
/**
|
||||
* PANDA 3D SOFTWARE
|
||||
* Copyright (c) Carnegie Mellon University. All rights reserved.
|
||||
*
|
||||
* All use of this software is subject to the terms of the revised BSD
|
||||
* license. You should have received a copy of this license along
|
||||
* with this source code in a file named "LICENSE."
|
||||
*
|
||||
* @file cocoaPandaAppDelegate.h
|
||||
* @author Donny Lawrence
|
||||
* @date 2018-02-25
|
||||
*/
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
#import <AppKit/AppKit.h>
|
||||
|
||||
// Cocoa is picky about where and when certain methods are called in the initialization process.
|
||||
@interface CocoaPandaAppDelegate : NSObject<NSApplicationDelegate>
|
||||
|
||||
- (void)applicationDidFinishLaunching:(NSNotification *)notification;
|
||||
|
||||
@end
|
||||
|
|
@ -0,0 +1,23 @@
|
|||
/**
|
||||
* PANDA 3D SOFTWARE
|
||||
* Copyright (c) Carnegie Mellon University. All rights reserved.
|
||||
*
|
||||
* All use of this software is subject to the terms of the revised BSD
|
||||
* license. You should have received a copy of this license along
|
||||
* with this source code in a file named "LICENSE."
|
||||
*
|
||||
* @file cocoaPandaAppDelegate.mm
|
||||
* @author Donny Lawrence
|
||||
* @date 2018-02-25
|
||||
*/
|
||||
|
||||
#import "cocoaPandaAppDelegate.h"
|
||||
|
||||
@implementation CocoaPandaAppDelegate
|
||||
|
||||
- (void)applicationDidFinishLaunching:(NSNotification *)notification {
|
||||
// This only seems to work when called here.
|
||||
[NSApp activateIgnoringOtherApps:YES];
|
||||
}
|
||||
|
||||
@end
|
||||
|
|
@ -7,3 +7,4 @@
|
|||
#include "cocoaPandaView.mm"
|
||||
#include "cocoaPandaWindow.mm"
|
||||
#include "cocoaPandaWindowDelegate.mm"
|
||||
#include "cocoaPandaAppDelegate.mm"
|
||||
|
|
|
|||
Loading…
Reference in New Issue