From f7817f6987f83d84893466ee4f8a99af98ee643f Mon Sep 17 00:00:00 2001 From: Pietro Gagliardi Date: Sun, 6 Apr 2014 23:33:27 -0400 Subject: Added (untested; VM issues) code to handle Mac OS X Quit Dock menu items and other related stuff that may happen in the future. Will drop the TODO after I can test it. --- delegate_darwin.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'delegate_darwin.go') diff --git a/delegate_darwin.go b/delegate_darwin.go index 00bdf6e..a8140e2 100644 --- a/delegate_darwin.go +++ b/delegate_darwin.go @@ -12,6 +12,7 @@ This creates a class goAppDelegate that will be used as the delegate for /everyt - handles window close events (windowShouldClose:) - handles window resize events (windowDidResize:) - handles button click events (buttonClicked:) + - handles the application-global Quit event (such as from the Dock) (applicationShouldTerminate) */ // #cgo LDFLAGS: -lobjc -framework Foundation -framework AppKit @@ -45,6 +46,8 @@ var appDelegateSels = []selector{ "handling window resize events"}, selector{"buttonClicked:", uintptr(C.appDelegate_buttonClicked), sel_bool_id, "handling button clicks"}, + selector{"applicationShouldTerminate", uintptr(C._appDelegate_applicationShouldTerminate), sel_terminatereply, + "handling Quit menu items (such as from the Dock)/the AppQuit channel"}, } func mkAppDelegate() error { @@ -94,3 +97,12 @@ func appDelegate_buttonClicked(self C.id, sel C.SEL, button C.id) { sysData := getSysData(button) sysData.signal() } + +//export appDelegate_applicationShouldTerminate +func appDelegate_applicationShouldTerminate() { + // asynchronous so as to return control to the event loop + go func() { + AppQuit <- struct{}{} + }() + // xxx in bleh_darwin.m tells Cocoa not to quit +} -- cgit v1.2.3