CocoaExtension // Allow callAlert() to handle responses.
This commit is contained in:
parent
a3310be0e3
commit
7ffb4b96d6
|
@ -49,12 +49,16 @@ extension NSWindowController {
|
||||||
}
|
}
|
||||||
|
|
||||||
extension NSWindow {
|
extension NSWindow {
|
||||||
public func callAlert(title: String, text: String? = nil) {
|
@discardableResult public func callAlert(title: String, text: String? = nil) -> NSApplication.ModalResponse {
|
||||||
let alert = NSAlert()
|
let alert = NSAlert()
|
||||||
alert.messageText = title
|
alert.messageText = title
|
||||||
if let text = text { alert.informativeText = text }
|
if let text = text { alert.informativeText = text }
|
||||||
alert.addButton(withTitle: NSLocalizedString("OK", comment: ""))
|
alert.addButton(withTitle: NSLocalizedString("OK", comment: ""))
|
||||||
alert.beginSheetModal(for: self)
|
var result: NSApplication.ModalResponse = .alertFirstButtonReturn
|
||||||
|
alert.beginSheetModal(for: self) { theResponce in
|
||||||
|
result = theResponce
|
||||||
|
}
|
||||||
|
return result
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue