diff options
| author | Manolo Gouy <Manolo> | 2010-12-03 19:22:15 +0000 |
|---|---|---|
| committer | Manolo Gouy <Manolo> | 2010-12-03 19:22:15 +0000 |
| commit | 0861422c71187a019ec6c253da6f2d9c8d8a73d3 (patch) | |
| tree | 907c0a8fc28ba1a85c7f3e6c9c0165274547ecce /src | |
| parent | 286e5231258cfcb7ab53b41fe1c9445638a567be (diff) | |
Improved interaction with non-FLTK windows.
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@7946 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
Diffstat (limited to 'src')
| -rw-r--r-- | src/Fl_cocoa.mm | 27 |
1 files changed, 18 insertions, 9 deletions
diff --git a/src/Fl_cocoa.mm b/src/Fl_cocoa.mm index 51c4df245..e837a0fc0 100644 --- a/src/Fl_cocoa.mm +++ b/src/Fl_cocoa.mm @@ -672,15 +672,6 @@ static double do_queued_events( double time = 0.0 ) } 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 @@ extern "C" { - (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 @@ extern "C" { } } } +- (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 @@ void fl_open_display() { }; EventHandlerUPP textHandler = NewEventHandlerUPP( carbonTextHandler ); InstallEventHandler(GetEventDispatcherTarget(), textHandler, 1, textEvents, NULL, 0L); + + [[NSNotificationCenter defaultCenter] addObserver:mydelegate + selector:@selector(anywindowwillclosenotif:) + name:NSWindowWillCloseNotification + object:nil]; } } |
