From dff7ed33218f40980b7da57d730c47a43dd27522 Mon Sep 17 00:00:00 2001 From: Pietro Gagliardi Date: Sun, 29 Jun 2014 03:09:01 -0400 Subject: Migrated the Mac OS X delegate code to the new API. --- delegateuitask_darwin.m | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) (limited to 'delegateuitask_darwin.m') diff --git a/delegateuitask_darwin.m b/delegateuitask_darwin.m index ed912eb..84be5be 100644 --- a/delegateuitask_darwin.m +++ b/delegateuitask_darwin.m @@ -63,8 +63,7 @@ extern NSRect dummyRect; - (BOOL)windowShouldClose:(id)win { - appDelegate_windowShouldClose(win); - return NO; // don't close + return appDelegate_windowShouldClose(win); } - (void)windowDidResize:(NSNotification *)n @@ -79,8 +78,18 @@ extern NSRect dummyRect; - (NSApplicationTerminateReply)applicationShouldTerminate:(NSApplication *)app { - appDelegate_applicationShouldTerminate(); - return NSTerminateCancel; + NSArray *windows; + NSUInteger i; + + // try to close all windows + windows = [NSApp windows]; + for (i = 0; i < [windows count]; i++) + [[windows objectAtIndex:i] performClose:self]; + // if any windows are left, cancel + if ([[NSApp windows] count] != 0) + return NSTerminateCancel; + // no windows are left; we're good + return NSTerminateNow; } - (void)alertDidEnd:(NSAlert *)alert returnCode:(NSInteger)returnCode contextInfo:(void *)chan -- cgit v1.2.3