From e2f3a11a33802144b152a636c4832936c2df1071 Mon Sep 17 00:00:00 2001 From: Lea Anthony Date: Tue, 28 Dec 2021 20:04:19 +1100 Subject: [PATCH] [mac] Fix for cancelling Dialogs. Fixes #1047 --- v2/internal/frontend/desktop/darwin/WailsContext.m | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/v2/internal/frontend/desktop/darwin/WailsContext.m b/v2/internal/frontend/desktop/darwin/WailsContext.m index e7c49409..e5608122 100644 --- a/v2/internal/frontend/desktop/darwin/WailsContext.m +++ b/v2/internal/frontend/desktop/darwin/WailsContext.m @@ -540,6 +540,10 @@ // Setup callback handler [dialog beginSheetModalForWindow:self.mainWindow completionHandler:^(NSModalResponse returnCode) { + if ( returnCode != NSModalResponseOK) { + processOpenFileDialogResponse("[]"); + return; + } NSMutableArray *arr = [NSMutableArray new]; for (NSURL *url in [dialog URLs]) { [arr addObject:[url path]]; @@ -592,10 +596,12 @@ // Setup callback handler [dialog beginSheetModalForWindow:self.mainWindow completionHandler:^(NSModalResponse returnCode) { - NSURL *url = [dialog URL]; - if ( url != nil ) { - processSaveFileDialogResponse([url.path UTF8String]); - return; + if ( returnCode == NSModalResponseOK ) { + NSURL *url = [dialog URL]; + if ( url != nil ) { + processSaveFileDialogResponse([url.path UTF8String]); + return; + } } processSaveFileDialogResponse(""); }];