From: <ka...@us...> - 2012-11-10 00:42:41
|
Revision: 3822 http://java-game-lib.svn.sourceforge.net/java-game-lib/?rev=3822&view=rev Author: kappa1 Date: 2012-11-10 00:42:34 +0000 (Sat, 10 Nov 2012) Log Message: ----------- Switch to using the correct Cocoa method for Display.isCloseRequested() Modified Paths: -------------- branches/osx-java7/LWJGL/src/native/macosx/org_lwjgl_opengl_Display.m Modified: branches/osx-java7/LWJGL/src/native/macosx/org_lwjgl_opengl_Display.m =================================================================== --- branches/osx-java7/LWJGL/src/native/macosx/org_lwjgl_opengl_Display.m 2012-11-06 21:55:11 UTC (rev 3821) +++ branches/osx-java7/LWJGL/src/native/macosx/org_lwjgl_opengl_Display.m 2012-11-10 00:42:34 UTC (rev 3822) @@ -78,16 +78,14 @@ return default_format; } -- (void) windowWillClose:(NSNotification *)notification -{ - MacOSXKeyableWindow *closingWindow = [notification object]; - - if (_parent != nil && closingWindow == _parent->window) { +- (BOOL)windowShouldClose:(id)sender { + if (_parent != nil) { JNIEnv *env = attachCurrentThread(); jclass display_class = (*env)->GetObjectClass(env, _parent->jdisplay); jmethodID close_callback = (*env)->GetMethodID(env, display_class, "doHandleQuit", "()V"); (*env)->CallVoidMethod(env, _parent->jdisplay, close_callback); } + return NO; } - (id)initWithFrame:(NSRect)frameRect pixelFormat:(NSOpenGLPixelFormat*)format @@ -163,18 +161,10 @@ } - (void)setParent:(MacOSXWindowInfo*)parent { - // Un-register for native window close events if we have a parent window already - if (_parent != nil) { - [[NSNotificationCenter defaultCenter] removeObserver:self - name:NSWindowWillCloseNotification - object:_parent->window]; - } _parent = parent; - // Register for native window close events if we now have a parent window + // Set this NSView as delegate to get native window close events for windowShouldClose method if (_parent != nil) { - [[NSNotificationCenter defaultCenter] addObserver:self - selector:@selector(windowWillClose:) name:NSWindowWillCloseNotification - object:_parent->window]; + [_parent->window setDelegate:self]; } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |