ctlIME // Optimizing modifier key conditions (Rebased).

- Flag Change Conditioning shall not get removed. Otherwise, when in the empty state, the first character being input won't be parsed by the IME.
- "return false" is the one that passing trash data to the "still nothing" section of the KeyHandler. Removing the "still nothing" allows these trash data to be passed to IMK but can lead to problems like misbehaved F1-F12 keys, etc., plus triggering "NSInternalInconsistencyException" for each modifier key input.
This commit is contained in:
ShikiSuen 2022-03-20 12:57:17 +08:00
parent 9ee97aeafb
commit 87dbc800c2
1 changed files with 11 additions and 14 deletions

View File

@ -188,25 +188,22 @@ class ctlInputMethod: IMKInputController {
override func handle(_ event: NSEvent!, client: Any!) -> Bool {
if event.type == .flagsChanged {
let functionKeyKeyboardLayoutID = mgrPrefs.functionKeyboardLayout
let basisKeyboardLayoutID = mgrPrefs.basisKeyboardLayout
if functionKeyKeyboardLayoutID == basisKeyboardLayoutID {
return false
}
// flags使 KeyHandler
// flags
// event.type == .flagsChanged return false
// NSInternalInconsistencyException
if (mgrPrefs.functionKeyboardLayout != mgrPrefs.basisKeyboardLayout) && (event.type == .flagsChanged) {
let includeShift = mgrPrefs.functionKeyKeyboardLayoutOverrideIncludeShiftKey
if event.modifierFlags.contains(.capsLock) ||
if (event.modifierFlags == .capsLock ||
event.modifierFlags.contains(.command) ||
event.modifierFlags.contains(.option) ||
event.modifierFlags.contains(.control) ||
event.modifierFlags.contains(.function) ||
(event.modifierFlags.contains(.shift) && includeShift) {
(client as? IMKTextInput)?.overrideKeyboard(withKeyboardNamed: functionKeyKeyboardLayoutID)
return false
(event.modifierFlags.contains(.shift) && includeShift)) {
(client as? IMKTextInput)?.overrideKeyboard(withKeyboardNamed: mgrPrefs.functionKeyboardLayout)
} else {
(client as? IMKTextInput)?.overrideKeyboard(withKeyboardNamed: mgrPrefs.basisKeyboardLayout)
}
(client as? IMKTextInput)?.overrideKeyboard(withKeyboardNamed: basisKeyboardLayoutID)
return false
}