aboutsummaryrefslogtreecommitdiff
path: root/gui/browser_osx.mm
diff options
context:
space:
mode:
Diffstat (limited to 'gui/browser_osx.mm')
-rw-r--r--gui/browser_osx.mm9
1 files changed, 9 insertions, 0 deletions
diff --git a/gui/browser_osx.mm b/gui/browser_osx.mm
index cfb70a3f65..6c5f036e8f 100644
--- a/gui/browser_osx.mm
+++ b/gui/browser_osx.mm
@@ -29,6 +29,7 @@
#include "common/system.h"
#include "common/algorithm.h"
#include "common/translation.h"
+#include "common/events.h"
#include <AppKit/NSNibDeclarations.h>
#include <AppKit/NSOpenPanel.h>
@@ -170,6 +171,14 @@ int BrowserDialog::runModal() {
[showHiddenFilesButton release];
[showHiddenFilesController release];
+ // While the native macOS file browser is open, any input events (e.g. keypresses) are
+ // still received by the NSApplication. With SDL backend for example this results in the
+ // events beeing queued and processed after we return, thus dispatching events that were
+ // intended for the native file browser. For example: pressing Esc to cancel the native
+ // macOS file browser would cause the application to quit in addition to closing the
+ // file browser. To avoid this happening clear all pending vents.
+ g_system->getEventManager()->getEventDispatcher()->clearEvents();
+
// If we were in fullscreen mode, switch back
if (wasFullscreen) {
g_system->beginGFXTransaction();