SessionCtl // Nil the inputHandler for inactive sessions.

This commit is contained in:
ShikiSuen 2022-11-30 00:21:48 +08:00
parent 65462f4ad0
commit b8d6a828ba
5 changed files with 19 additions and 15 deletions

View File

@ -18,7 +18,7 @@ import Shared
extension InputHandler {
///
/// - Remark: inputHandler.handleEvent() IMKCandidates
/// - Remark: inputHandler?.handleEvent() IMKCandidates
/// - Parameters:
/// - input:
/// - Returns: IMK

View File

@ -66,9 +66,7 @@ public class SessionCtl: IMKInputController {
private static var isASCIIModeForAllClients = false //
/// 調
var inputHandler: InputHandlerProtocol = InputHandler(
lm: LMMgr.currentLM, uom: LMMgr.currentUOM, pref: PrefMgr.shared
)
var inputHandler: InputHandlerProtocol?
///
public var state: IMEStateProtocol = IMEState.ofEmpty() {
didSet {
@ -113,10 +111,10 @@ public class SessionCtl: IMKInputController {
if oldValue != inputMode, inputMode != .imeModeNULL {
// ----------------------------
///
inputHandler.currentLM = LMMgr.currentLM //
inputHandler.currentUOM = LMMgr.currentUOM
inputHandler?.currentLM = LMMgr.currentLM //
inputHandler?.currentUOM = LMMgr.currentUOM
///
inputHandler.ensureKeyboardParser()
inputHandler?.ensureKeyboardParser()
///
syncBaseLMPrefs()
/// 調
@ -145,7 +143,10 @@ public class SessionCtl: IMKInputController {
override public init!(server: IMKServer!, delegate: Any!, client inputClient: Any!) {
super.init(server: server, delegate: delegate, client: inputClient)
DispatchQueue.main.async { [self] in
inputHandler.delegate = self
inputHandler = InputHandler(
lm: LMMgr.currentLM, uom: LMMgr.currentUOM, pref: PrefMgr.shared
)
inputHandler?.delegate = self
syncBaseLMPrefs()
//
activateServer(inputClient)
@ -175,6 +176,7 @@ extension SessionCtl {
/// 調
public func resetInputHandler(forceComposerCleanup forceCleanup: Bool = false) {
guard let inputHandler = inputHandler else { return }
var textToCommit = ""
//
let sansReading: Bool =
@ -198,12 +200,12 @@ extension SessionCtl {
DispatchQueue.main.async { [self] in
if isActivated { return }
// activateServer nil
//
inputHandler.delegate = self
// setValue() IMK activateServer() setValue()
inputHandler.clear() // handle State.Empty()
inputHandler.ensureKeyboardParser()
inputHandler = InputHandler(
lm: LMMgr.currentLM, uom: LMMgr.currentUOM, pref: PrefMgr.shared
)
inputHandler?.delegate = self
syncBaseLMPrefs()
Self.theShiftKeyDetector.alsoToggleWithLShift = PrefMgr.shared.togglingAlphanumericalModeWithLShift
Self.isVerticalTyping = isVerticalTyping
@ -231,6 +233,7 @@ extension SessionCtl {
isActivated = false
resetInputHandler() // Empty
switchState(IMEState.ofDeactivated())
inputHandler = nil
// IMK nil IMK
if candidateUI is CtlCandidateTDK {
candidateUI = nil

View File

@ -98,6 +98,7 @@ extension SessionCtl: CtlCandidateDelegate {
}
public func candidatePairSelected(at index: Int) {
guard let inputHandler = inputHandler else { return }
if state.type == .ofSymbolTable, (0..<state.node.members.count).contains(index) {
let node = state.node.members[index]
if !node.members.isEmpty {

View File

@ -101,7 +101,7 @@ extension SessionCtl {
if event.type == .flagsChanged { return false }
///
guard client() != nil else { return false }
guard let inputHandler = inputHandler, client() != nil else { return false }
var eventToDeal = event

View File

@ -65,7 +65,7 @@ extension SessionCtl {
}
showTooltip(newState.tooltip, duration: 1) //
clearInlineDisplay()
inputHandler.clear()
inputHandler?.clear()
case .ofInputting:
candidateUI?.visible = false
commit(text: newState.textToCommit)