Author: manolo
Date: 2010-12-03 11:22:15 -0800 (Fri, 03 Dec 2010)
New Revision: 7946
Log:
Improved interaction with non-FLTK windows.
Modified:
branches/branch-1.3/src/Fl_cocoa.mm
Modified: branches/branch-1.3/src/Fl_cocoa.mm
===================================================================
--- branches/branch-1.3/src/Fl_cocoa.mm 2010-12-03 17:40:05 UTC (rev 7945)
+++ branches/branch-1.3/src/Fl_cocoa.mm 2010-12-03 19:22:15 UTC (rev 7946)
@@ -672,15 +672,6 @@
}
fl_unlock_function();
-
- // necessary so that after closing a non-FLTK window (e.g.,
Fl_Native_File_Chooser)
- // the front window turns key again
- NSWindow *nsk = [NSApp keyWindow];
- NSWindow *nsm = [NSApp mainWindow];
- if ([nsm isMemberOfClass:[FLWindow class]] && (nsk == nil || ( ! [nsk
isMemberOfClass:[FLWindow class]] &&
- ! [nsk isVisible] ) ) ) {
- [nsm makeKeyAndOrderFront:nil];
- }
NSEvent *event = [NSApp nextEventMatchingMask:NSAnyEventMask
untilDate:[NSDate
dateWithTimeIntervalSinceNow:time]
inMode:NSDefaultRunLoopMode
dequeue:YES];
@@ -1142,6 +1133,7 @@
- (void)windowDidDeminiaturize:(NSNotification *)notif;
- (void)windowDidMiniaturize:(NSNotification *)notif;
- (void)windowWillClose:(NSNotification *)notif;
+- (void)anywindowwillclosenotif:(NSNotification *)notif;
-
(NSApplicationTerminateReply)applicationShouldTerminate:(NSApplication*)sender;
- (void)applicationDidBecomeActive:(NSNotification *)notify;
- (void)applicationWillResignActive:(NSNotification *)notify;
@@ -1218,6 +1210,18 @@
}
}
}
+- (void)anywindowwillclosenotif:(NSNotification *)notif
+{
+ // necessary so that after closing a non-FLTK window (e.g.,
Fl_Native_File_Chooser)
+ // the front window turns key again
+ NSWindow *closing = (NSWindow*)[notif object];
+ if ([closing isMemberOfClass:[FLWindow class]]) return;
+ NSWindow *nsk = [NSApp keyWindow];
+ NSWindow *nsm = [NSApp mainWindow];
+ if ([nsm isMemberOfClass:[FLWindow class]] && nsk == nil) {
+ [nsm makeKeyAndOrderFront:nil];
+ }
+}
-
(NSApplicationTerminateReply)applicationShouldTerminate:(NSApplication*)sender
{
fl_lock_function();
@@ -1423,6 +1427,11 @@
};
EventHandlerUPP textHandler = NewEventHandlerUPP( carbonTextHandler );
InstallEventHandler(GetEventDispatcherTarget(), textHandler, 1,
textEvents, NULL, 0L);
+
+ [[NSNotificationCenter defaultCenter] addObserver:mydelegate
+ selector:@selector(anywindowwillclosenotif:)
+ name:NSWindowWillCloseNotification
+ object:nil];
}
}
_______________________________________________
fltk-commit mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk-commit