From 60578d63f4b4a0527e1e6ec999147b2abf20c479 Mon Sep 17 00:00:00 2001 From: Stefan Csomor Date: Tue, 22 Apr 2014 21:21:19 +0000 Subject: [PATCH] add our own Apple Event handler for the quit app event, fixes #16200 git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@76392 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/osx/cocoa/utils.mm | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/osx/cocoa/utils.mm b/src/osx/cocoa/utils.mm index 0d42873f1b..61990badcc 100644 --- a/src/osx/cocoa/utils.mm +++ b/src/osx/cocoa/utils.mm @@ -60,7 +60,10 @@ void wxBell() [appleEventManager setEventHandler:self andSelector:@selector(handleOpenAppEvent:withReplyEvent:) forEventClass:kCoreEventClass andEventID:kAEOpenApplication]; - + + [appleEventManager setEventHandler:self andSelector:@selector(handleQuitAppEvent:withReplyEvent:) + forEventClass:kCoreEventClass andEventID:kAEQuitApplication]; + wxTheApp->OSXOnWillFinishLaunching(); } @@ -134,6 +137,16 @@ void wxBell() wxTheApp->OSXStoreOpenURL(cf.AsString()); } +- (void)handleQuitAppEvent:(NSAppleEventDescriptor *)event + withReplyEvent:(NSAppleEventDescriptor *)replyEvent +{ + if ( wxTheApp->OSXOnShouldTerminate() ) + { + wxTheApp->OSXOnWillTerminate(); + wxTheApp->ExitMainLoop(); + } +} + - (void)handleOpenAppEvent:(NSAppleEventDescriptor *)event withReplyEvent:(NSAppleEventDescriptor *)replyEvent {