From b172ab2e37896d36292660f6cc15987fb88ddf57 Mon Sep 17 00:00:00 2001 From: Pietro Gagliardi Date: Sun, 8 Jun 2014 12:36:55 -0400 Subject: Added new MsgBox() behavior on Mac OS X. Now we can finally remove MsgBox() from the TODOs! :D --- dialog_darwin.m | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) (limited to 'dialog_darwin.m') diff --git a/dialog_darwin.m b/dialog_darwin.m index 6bbad61..d37956f 100644 --- a/dialog_darwin.m +++ b/dialog_darwin.m @@ -1,6 +1,7 @@ // 15 may 2014 #include "objc_darwin.h" +#include "_cgo_export.h" #import // see delegateuitask_darwin.m @@ -23,7 +24,7 @@ #define to(T, x) ((T *) (x)) #define toNSWindow(x) to(NSWindow, (x)) -static void alert(id parent, NSString *primary, NSString *secondary, NSAlertStyle style) +static void alert(id parent, NSString *primary, NSString *secondary, NSAlertStyle style, void *chan) { NSAlert *box; @@ -35,20 +36,20 @@ static void alert(id parent, NSString *primary, NSString *secondary, NSAlertStyl // TODO is there a named constant? will also need to be changed when we add different dialog types [box addButtonWithTitle:@"OK"]; if (parent == nil) - [box runModal]; + dialog_send(chan, (intptr_t) [box runModal]); else [box beginSheetModalForWindow:toNSWindow(parent) modalDelegate:[NSApp delegate] didEndSelector:@selector(alertDidEnd:returnCode:contextInfo:) - contextInfo:NULL]; + contextInfo:chan]; } -void msgBox(id parent, id primary, id secondary) +void msgBox(id parent, id primary, id secondary, void *chan) { - alert(parent, (NSString *) primary, (NSString *) secondary, NSInformationalAlertStyle); + alert(parent, (NSString *) primary, (NSString *) secondary, NSInformationalAlertStyle, chan); } -void msgBoxError(id parent, id primary, id secondary) +void msgBoxError(id parent, id primary, id secondary, void *chan) { - alert(parent, (NSString *) primary, (NSString *) secondary, NSCriticalAlertStyle); + alert(parent, (NSString *) primary, (NSString *) secondary, NSCriticalAlertStyle, chan); } -- cgit v1.2.3