Author: manolo
Date: 2011-10-30 10:32:07 -0700 (Sun, 30 Oct 2011)
New Revision: 9162
Log:
Mac OS: simpler processing of window closing events.

Modified:
   branches/branch-3.0/src/fltk3/cocoa.mm

Modified: branches/branch-3.0/src/fltk3/cocoa.mm
===================================================================
--- branches/branch-3.0/src/fltk3/cocoa.mm      2011-10-30 17:23:42 UTC (rev 
9161)
+++ branches/branch-3.0/src/fltk3/cocoa.mm      2011-10-30 17:32:07 UTC (rev 
9162)
@@ -931,7 +931,7 @@
 - (void)windowDidBecomeMain:(NSNotification *)notif;
 - (void)windowDidDeminiaturize:(NSNotification *)notif;
 - (void)windowDidMiniaturize:(NSNotification *)notif;
-- (void)windowWillClose:(NSNotification *)notif;
+- (void)anyWindowWillClose:(NSNotification *)notif;
 - 
(NSApplicationTerminateReply)applicationShouldTerminate:(NSApplication*)sender;
 - (void)applicationDidBecomeActive:(NSNotification *)notify;
 - (void)applicationDidChangeScreenParameters:(NSNotification *)aNotification;
@@ -1018,7 +1018,7 @@
   fltk3::handle(fltk3::HIDE, window);
   fl_unlock_function();
 }
-- (void)windowWillClose:(NSNotification *)notif
+- (void)anyWindowWillClose:(NSNotification *)notif
 {
   fl_lock_function();
   if ([[notif object] isKeyWindow]) {
@@ -1029,7 +1029,7 @@
       w = fltk3::next_window(w);
     }
     if (w) {
-      [(FLWindow*)Fl_X::i(w)->xid makeKeyAndOrderFront:nil];
+      [(FLWindow*)Fl_X::i(w)->xid makeKeyWindow];
     }
   }
   fl_unlock_function();
@@ -1291,6 +1291,10 @@
     if (![NSApp servicesMenu]) createAppleMenu();
     fl_system_menu = [NSApp mainMenu];
     main_screen_height = [[[NSScreen screens] objectAtIndex:0] 
frame].size.height;
+    [[NSNotificationCenter defaultCenter] addObserver:[NSApp delegate] 
+                                            
selector:@selector(anyWindowWillClose:) 
+                                                
name:NSWindowWillCloseNotification 
+                                              object:nil];
   }
 }
 
@@ -2825,7 +2829,6 @@
 }
 - (void)showPanel;
 - (void)printPanel;
-- (void)closePanel:(NSNotification *)notif;
 @end
 @implementation FLaboutItemTarget
 - (void)showPanel
@@ -2837,16 +2840,7 @@
                                FL_MAJOR_VERSION, FL_MINOR_VERSION ]] 
autorelease], @"Credits",
              nil];
   [NSApp orderFrontStandardAboutPanelWithOptions:options];
-  [[NSNotificationCenter defaultCenter] addObserver:self 
-                                          selector:@selector(closePanel:) 
-                                              
name:NSWindowWillCloseNotification 
-                                            object:[NSApp keyWindow]];
 }
-- (void)closePanel:(NSNotification *)notif
-{
-  [[NSApp delegate] windowWillClose:notif];
-  [[NSNotificationCenter defaultCenter] removeObserver:self];
-}
 //#include <fltk3/PostScript.h>
 - (void)printPanel
 {

_______________________________________________
fltk-commit mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk-commit

Reply via email to