Catch Command+Q shortcut and get it to call Display.isCloseRequested()

This commit is contained in:
kappaOne 2013-02-05 21:28:08 +00:00
parent e15d172087
commit 93a169b27b
1 changed files with 18 additions and 0 deletions

View File

@ -178,6 +178,19 @@ 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) {
@ -529,6 +542,11 @@ JNIEXPORT jobject JNICALL Java_org_lwjgl_opengl_MacOSXDisplay_nCreateWindow(JNIE
CGLDisable(cgcontext, kCGLCESurfaceBackingSize);
}
else {
// Cache the necessary info for window-close callbacks into the JVM
if (window_info->jdisplay == NULL) {
window_info->jdisplay = (*env)->NewGlobalRef(env, this);
}
// set a fixed backbuffer size for fullscreen
CGLContextObj cgcontext = (CGLContextObj)[window_info->context CGLContextObj];
GLint dim[2] = {width, height};