From c14e1569264b0d8397f913468c65847c10d6e4c9 Mon Sep 17 00:00:00 2001 From: Roopesh Chander Date: Sat, 5 Jan 2019 14:16:28 +0530 Subject: [PATCH] macOS: Present errors as a sheet when applicable --- WireGuard/WireGuard/UI/macOS/ErrorPresenter.swift | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/WireGuard/WireGuard/UI/macOS/ErrorPresenter.swift b/WireGuard/WireGuard/UI/macOS/ErrorPresenter.swift index c83a339..69ea731 100644 --- a/WireGuard/WireGuard/UI/macOS/ErrorPresenter.swift +++ b/WireGuard/WireGuard/UI/macOS/ErrorPresenter.swift @@ -9,7 +9,15 @@ class ErrorPresenter: ErrorPresenterProtocol { alert.messageText = title alert.informativeText = message onPresented?() - alert.runModal() - onDismissal?() + if let sourceVC = sourceVC as? NSViewController { + NSApp.activate(ignoringOtherApps: true) + sourceVC.view.window!.makeKeyAndOrderFront(nil) + alert.beginSheetModal(for: sourceVC.view.window!) { _ in + onDismissal?() + } + } else { + alert.runModal() + onDismissal?() + } } }