ctlIME // Stop detecting flagsChanged when handling layouts.
- Also optimizing modifier key conditions.
This commit is contained in:
parent
7e10aca1f6
commit
73f95e0d9c
|
@ -188,26 +188,19 @@ 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 是否有 change,因為 InputMethodKit 有時就是會無法判斷。
|
||||
if mgrPrefs.functionKeyboardLayout != mgrPrefs.basisKeyboardLayout {
|
||||
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
|
||||
(client as? IMKTextInput)?.overrideKeyboard(withKeyboardNamed: mgrPrefs.functionKeyboardLayout)
|
||||
} else {
|
||||
(client as? IMKTextInput)?.overrideKeyboard(withKeyboardNamed: mgrPrefs.basisKeyboardLayout)
|
||||
}
|
||||
(client as? IMKTextInput)?.overrideKeyboard(withKeyboardNamed: basisKeyboardLayoutID)
|
||||
return false
|
||||
}
|
||||
|
||||
var textFrame = NSRect.zero
|
||||
|
|
Loading…
Reference in New Issue