CtlClientListMgr // Move callAlert() to CocoaExtension.
This commit is contained in:
parent
bf4f3a22fb
commit
4d03773b1a
|
@ -48,6 +48,16 @@ extension NSWindowController {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
extension NSWindow {
|
||||||
|
public func callAlert(title: String, text: String? = nil) {
|
||||||
|
let alert = NSAlert()
|
||||||
|
alert.messageText = title
|
||||||
|
if let text = text { alert.informativeText = text }
|
||||||
|
alert.addButton(withTitle: NSLocalizedString("OK", comment: ""))
|
||||||
|
alert.beginSheetModal(for: self)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
extension IMKCandidates {
|
extension IMKCandidates {
|
||||||
/// 設定選字窗的顯示位置。
|
/// 設定選字窗的顯示位置。
|
||||||
///
|
///
|
||||||
|
|
|
@ -43,16 +43,6 @@ extension CtlClientListMgr {
|
||||||
PrefMgr.shared.clientsIMKTextInputIncapable.count
|
PrefMgr.shared.clientsIMKTextInputIncapable.count
|
||||||
}
|
}
|
||||||
|
|
||||||
func callAlert(_ window: NSWindow, title: String, text: String? = nil) {
|
|
||||||
let alert = NSAlert()
|
|
||||||
alert.messageText = title
|
|
||||||
if let text = text {
|
|
||||||
alert.informativeText = text
|
|
||||||
}
|
|
||||||
alert.addButton(withTitle: NSLocalizedString("OK", comment: ""))
|
|
||||||
alert.beginSheetModal(for: window)
|
|
||||||
}
|
|
||||||
|
|
||||||
@IBAction func btnAddClientClicked(_: Any) {
|
@IBAction func btnAddClientClicked(_: Any) {
|
||||||
guard let window = window else { return }
|
guard let window = window else { return }
|
||||||
let alert = NSAlert()
|
let alert = NSAlert()
|
||||||
|
@ -119,18 +109,18 @@ extension CtlClientListMgr {
|
||||||
)
|
)
|
||||||
let text = url.path + "\n\n" + NSLocalizedString("Please try again.", comment: "")
|
let text = url.path + "\n\n" + NSLocalizedString("Please try again.", comment: "")
|
||||||
guard let bundle = Bundle(url: url) else {
|
guard let bundle = Bundle(url: url) else {
|
||||||
self.callAlert(window, title: title, text: text)
|
self.window?.callAlert(title: title, text: text)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
guard let identifier = bundle.bundleIdentifier else {
|
guard let identifier = bundle.bundleIdentifier else {
|
||||||
self.callAlert(window, title: title, text: text)
|
self.window?.callAlert(title: title, text: text)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if PrefMgr.shared.clientsIMKTextInputIncapable.contains(identifier) {
|
if PrefMgr.shared.clientsIMKTextInputIncapable.contains(identifier) {
|
||||||
title = NSLocalizedString(
|
title = NSLocalizedString(
|
||||||
"The selected item's identifier is already in the list.", comment: ""
|
"The selected item's identifier is already in the list.", comment: ""
|
||||||
)
|
)
|
||||||
self.callAlert(window, title: title, text: identifier + "\n\n" + url.path)
|
self.window?.callAlert(title: title, text: identifier + "\n\n" + url.path)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
self.applyNewValue(identifier)
|
self.applyNewValue(identifier)
|
||||||
|
|
Loading…
Reference in New Issue