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 {