SessionCtl // Implement the alternative init().
This commit is contained in:
parent
44dc2ee267
commit
164366d8fa
|
@ -169,6 +169,12 @@ public class SessionCtl: IMKInputController {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// 對用以設定委任物件的控制器型別進行初期化處理。
|
||||||
|
override public init() {
|
||||||
|
super.init()
|
||||||
|
construct(client: client())
|
||||||
|
}
|
||||||
|
|
||||||
/// 對用以設定委任物件的控制器型別進行初期化處理。
|
/// 對用以設定委任物件的控制器型別進行初期化處理。
|
||||||
///
|
///
|
||||||
/// inputClient 參數是客體應用側存在的用以藉由 IMKServer 伺服器向輸入法傳訊的物件。該物件始終遵守 IMKTextInput 協定。
|
/// inputClient 參數是客體應用側存在的用以藉由 IMKServer 伺服器向輸入法傳訊的物件。該物件始終遵守 IMKTextInput 協定。
|
||||||
|
@ -179,6 +185,12 @@ public class SessionCtl: IMKInputController {
|
||||||
/// - inputClient: 用以接受輸入的客體應用物件
|
/// - inputClient: 用以接受輸入的客體應用物件
|
||||||
override public init!(server: IMKServer!, delegate: Any!, client inputClient: Any!) {
|
override public init!(server: IMKServer!, delegate: Any!, client inputClient: Any!) {
|
||||||
super.init(server: server, delegate: delegate, client: inputClient)
|
super.init(server: server, delegate: delegate, client: inputClient)
|
||||||
|
let theClient = inputClient as? (IMKTextInput & NSObjectProtocol)
|
||||||
|
construct(client: theClient)
|
||||||
|
}
|
||||||
|
|
||||||
|
/// 所有建構子都會執行的共用部分,在 super.init() 之後執行。
|
||||||
|
private func construct(client theClient: (IMKTextInput & NSObjectProtocol)? = nil) {
|
||||||
DispatchQueue.main.async { [self] in
|
DispatchQueue.main.async { [self] in
|
||||||
inputHandler = InputHandler(
|
inputHandler = InputHandler(
|
||||||
lm: LMMgr.currentLM, uom: LMMgr.currentUOM, pref: PrefMgr.shared
|
lm: LMMgr.currentLM, uom: LMMgr.currentUOM, pref: PrefMgr.shared
|
||||||
|
@ -186,7 +198,8 @@ public class SessionCtl: IMKInputController {
|
||||||
inputHandler?.delegate = self
|
inputHandler?.delegate = self
|
||||||
syncBaseLMPrefs()
|
syncBaseLMPrefs()
|
||||||
// 下述兩行很有必要,否則輸入法會在手動重啟之後無法立刻生效。
|
// 下述兩行很有必要,否則輸入法會在手動重啟之後無法立刻生效。
|
||||||
activateServer(inputClient)
|
let maybeClient = theClient ?? client()
|
||||||
|
activateServer(maybeClient)
|
||||||
// GCD 會觸發 didSet,所以不用擔心。
|
// GCD 會觸發 didSet,所以不用擔心。
|
||||||
inputMode = .init(rawValue: PrefMgr.shared.mostRecentInputMode) ?? .imeModeNULL
|
inputMode = .init(rawValue: PrefMgr.shared.mostRecentInputMode) ?? .imeModeNULL
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue