diff --git a/src/native/macosx/org_lwjgl_opengl_Display.m b/src/native/macosx/org_lwjgl_opengl_Display.m index e20e1057..81c9b5fa 100644 --- a/src/native/macosx/org_lwjgl_opengl_Display.m +++ b/src/native/macosx/org_lwjgl_opengl_Display.m @@ -85,6 +85,11 @@ static NSAutoreleasePool *pool; return NO; } +- (NSApplicationTerminateReply)applicationShouldTerminate:(NSApplication *)sender { + [self windowShouldClose:nil]; + return NSTerminateCancel; +} + - (id)initWithFrame:(NSRect)frameRect pixelFormat:(NSOpenGLPixelFormat*)format { self = [super initWithFrame:frameRect]; if (self != nil) { @@ -178,19 +183,6 @@ static NSAutoreleasePool *pool; (*env)->CallVoidMethod(env, _parent->jkeyboard, keyup, [event keyCode], charcode, time); } -- (BOOL)performKeyEquivalent:(NSEvent *)event { - // if command key down - if (([event modifierFlags] & NSDeviceIndependentModifierFlagsMask) == NSCommandKeyMask) { - // and if q key down - if ([[event charactersIgnoringModifiers] isEqualToString:@"q"]) { - [self windowShouldClose:nil]; - return YES; - } - } - - return NO; -} - - (void)flagsChanged:(NSEvent *)event { JNIEnv *env = attachCurrentThread(); if (env == nil || event == nil || _parent == nil || _parent->jkeyboard == nil) { @@ -490,6 +482,9 @@ JNIEXPORT jobject JNICALL Java_org_lwjgl_opengl_MacOSXDisplay_nCreateWindow(JNIE window_info->view = [[MacOSXOpenGLView alloc] initWithFrame:view_rect pixelFormat:peer_info->pixel_format]; [window_info->view setAutoresizingMask:NSViewWidthSizable | NSViewHeightSizable]; + // set nsapp delegate for catching app quit events + [NSApp setDelegate:window_info->view]; + if (window_info->context != nil) { [window_info->view setOpenGLContext:window_info->context]; }