ctlIME // Sacrificing advanced keyLayout feature.

- It is now impossible to ensure the reliability of this feature.
This commit is contained in:
ShikiSuen 2022-03-28 11:10:03 +08:00
parent 5b6a455523
commit 9bc0f485e8
1 changed files with 5 additions and 19 deletions

View File

@ -63,9 +63,9 @@ class ctlInputMethod: IMKInputController {
// MARK: - Keyboard Layout Specifier
@objc func setKeyLayout(isfunctionKeyboardLayout: Bool = false) {
@objc func setKeyLayout() {
let client = client().self as IMKTextInput
client.overrideKeyboard(withKeyboardNamed: isfunctionKeyboardLayout ? mgrPrefs.functionKeyboardLayout : mgrPrefs.basisKeyboardLayout)
client.overrideKeyboard(withKeyboardNamed: mgrPrefs.basisKeyboardLayout)
}
// MARK: - IMKInputController methods
@ -142,7 +142,7 @@ class ctlInputMethod: IMKInputController {
}
// NSMenu modified key
setKeyLayout(isfunctionKeyboardLayout: false)
setKeyLayout()
return menu
}
@ -152,7 +152,7 @@ class ctlInputMethod: IMKInputController {
UserDefaults.standard.synchronize()
// Override the keyboard layout to the basic one.
(client as? IMKTextInput)?.overrideKeyboard(withKeyboardNamed: mgrPrefs.basisKeyboardLayout)
setKeyLayout()
// reset the state
currentCandidateClient = nil
@ -181,7 +181,7 @@ class ctlInputMethod: IMKInputController {
mgrLangModel.loadDataModel(newInputMode)
// Remember to override the keyboard layout again -- treat this as an activate event.
(client as? IMKTextInput)?.overrideKeyboard(withKeyboardNamed: mgrPrefs.basisKeyboardLayout)
setKeyLayout()
if keyHandler.inputMode != newInputMode {
UserDefaults.standard.synchronize()
@ -208,20 +208,6 @@ class ctlInputMethod: IMKInputController {
// event.type == .flagsChanged return false
// NSInternalInconsistencyException
if event.type == .flagsChanged {
// If no override is needed, just return NO.
if mgrPrefs.functionKeyboardLayout == mgrPrefs.basisKeyboardLayout {
return false
}
// Function key conditions met. Swift cannot handle this.
if ObjCUtils.keyboardSwitchCondition(event) {
setKeyLayout(isfunctionKeyboardLayout: true)
(client as? IMKTextInput)?.overrideKeyboard(withKeyboardNamed: mgrPrefs.functionKeyboardLayout)
return false
}
// Revert to the basis layout when the function key is released. This step has to be standalone.
(client as? IMKTextInput)?.overrideKeyboard(withKeyboardNamed: mgrPrefs.basisKeyboardLayout)
return false
}