Correctly catch quit events instead of manually catching OS X hotkeys
This commit is contained in:
parent
93a169b27b
commit
409b3fea6d
|
@ -85,6 +85,11 @@ static NSAutoreleasePool *pool;
|
||||||
return NO;
|
return NO;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (NSApplicationTerminateReply)applicationShouldTerminate:(NSApplication *)sender {
|
||||||
|
[self windowShouldClose:nil];
|
||||||
|
return NSTerminateCancel;
|
||||||
|
}
|
||||||
|
|
||||||
- (id)initWithFrame:(NSRect)frameRect pixelFormat:(NSOpenGLPixelFormat*)format {
|
- (id)initWithFrame:(NSRect)frameRect pixelFormat:(NSOpenGLPixelFormat*)format {
|
||||||
self = [super initWithFrame:frameRect];
|
self = [super initWithFrame:frameRect];
|
||||||
if (self != nil) {
|
if (self != nil) {
|
||||||
|
@ -178,19 +183,6 @@ static NSAutoreleasePool *pool;
|
||||||
(*env)->CallVoidMethod(env, _parent->jkeyboard, keyup, [event keyCode], charcode, time);
|
(*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 {
|
- (void)flagsChanged:(NSEvent *)event {
|
||||||
JNIEnv *env = attachCurrentThread();
|
JNIEnv *env = attachCurrentThread();
|
||||||
if (env == nil || event == nil || _parent == nil || _parent->jkeyboard == nil) {
|
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 = [[MacOSXOpenGLView alloc] initWithFrame:view_rect pixelFormat:peer_info->pixel_format];
|
||||||
[window_info->view setAutoresizingMask:NSViewWidthSizable | NSViewHeightSizable];
|
[window_info->view setAutoresizingMask:NSViewWidthSizable | NSViewHeightSizable];
|
||||||
|
|
||||||
|
// set nsapp delegate for catching app quit events
|
||||||
|
[NSApp setDelegate:window_info->view];
|
||||||
|
|
||||||
if (window_info->context != nil) {
|
if (window_info->context != nil) {
|
||||||
[window_info->view setOpenGLContext:window_info->context];
|
[window_info->view setOpenGLContext:window_info->context];
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue