virtual void OSXOnWillFinishLaunching();
// immediately when the native event loop starts, no events have been served yet
virtual void OSXOnDidFinishLaunching();
-
+ // OS asks to terminate app, return no to stay running
+ virtual bool OSXOnShouldTerminate();
+ // before application terminates
+ virtual void OSXOnWillTerminate();
+
// Hide the application windows the same as the system hide command would do it.
void MacHideApp();
void wxApp::OSXOnDidFinishLaunching()
{
+
+}
+
+void wxApp::OSXOnWillTerminate()
+{
+ wxCloseEvent event;
+ event.SetCanVeto(false);
+ wxTheApp->OnEndSession(event);
+}
+
+bool wxApp::OSXOnShouldTerminate()
+{
+ wxCloseEvent event;
+ wxTheApp->OnQueryEndSession(event);
+ return !event.GetVeto();
}
//----------------------------------------------------------------------
- (NSApplicationTerminateReply)applicationShouldTerminate:(NSApplication *)sender
{
wxUnusedVar(sender);
- wxCloseEvent event;
- wxTheApp->OnQueryEndSession(event);
- if ( event.GetVeto() )
+ if ( !wxTheApp->OSXOnShouldTerminate() )
return NSTerminateCancel;
return NSTerminateNow;
- (void)applicationWillTerminate:(NSNotification *)application {
wxUnusedVar(application);
- wxCloseEvent event;
- event.SetCanVeto(false);
- wxTheApp->OnEndSession(event);
+ wxTheApp->OSXOnWillTerminate();
}
- (BOOL)applicationShouldTerminateAfterLastWindowClosed:(NSApplication *)sender