From 83da5ad0f112e45f1658722cb1c2f5fd3bd95895 Mon Sep 17 00:00:00 2001 From: Tony Garnock-Jones Date: Tue, 1 May 2012 16:09:43 -0400 Subject: [PATCH] Close app on window close --- gui_ocamlmsgAppDelegate.m | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/gui_ocamlmsgAppDelegate.m b/gui_ocamlmsgAppDelegate.m index ae9601a..532adad 100644 --- a/gui_ocamlmsgAppDelegate.m +++ b/gui_ocamlmsgAppDelegate.m @@ -19,6 +19,12 @@ - (void)applicationDidFinishLaunching:(NSNotification *)aNotification { task = [NSTask new]; + [[NSNotificationCenter defaultCenter] + addObserver: self + selector: @selector(mainWindowClosed:) + name: NSWindowWillCloseNotification + object: window]; + [[NSNotificationCenter defaultCenter] addObserver: self selector: @selector(taskStatusChanged:) @@ -83,4 +89,8 @@ [NSApp terminate: self]; } +- (void) mainWindowClosed: (NSNotification *) aNotification { + [NSApp terminate: self]; +} + @end