From a246e4c911d382a32ecbc0140e6d768c7d28140f Mon Sep 17 00:00:00 2001 From: Stefan Csomor Date: Fri, 25 Apr 2014 13:02:48 +0000 Subject: [PATCH] backport, add our own Apple Event handler for the quit app event, see #16200 git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_3_0_BRANCH@76395 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/osx/cocoa/utils.mm | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/osx/cocoa/utils.mm b/src/osx/cocoa/utils.mm index 9110334e44..4b4f003a7a 100644 --- a/src/osx/cocoa/utils.mm +++ b/src/osx/cocoa/utils.mm @@ -61,6 +61,9 @@ 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 {