macOS: Present errors as a sheet when applicable

This commit is contained in:
Roopesh Chander 2019-01-05 14:16:28 +05:30
parent ca5e90a70e
commit c14e156926
1 changed files with 10 additions and 2 deletions

View File

@ -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?()
}
}
}