From 62d28574d4af14304f250fbeabb40d8aaecbb61d Mon Sep 17 00:00:00 2001 From: ShikiSuen Date: Tue, 1 Mar 2022 22:18:59 +0800 Subject: [PATCH] KeyHandler // Let alphanumerical mode respect AppleKeyboardConverter. - Note that Apple Dynamic Keyboard Layout users need to press'n'hold ALT+SHIFT when typing uppercase letters. If this brings you inconveniences or causes hotkey conflicts with the app you are using, please consider using static keyboard layouts (like US keyboard layout, etc.) instead which sacrifices the on-screen bopomofo keyboard. --- Source/Modules/ControllerModules/KeyHandler.mm | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/Source/Modules/ControllerModules/KeyHandler.mm b/Source/Modules/ControllerModules/KeyHandler.mm index 3a245494..3cb060d6 100644 --- a/Source/Modules/ControllerModules/KeyHandler.mm +++ b/Source/Modules/ControllerModules/KeyHandler.mm @@ -272,18 +272,23 @@ static NSString *const kGraphVizOutputfile = @"/tmp/vChewing-visualization.dot"; return NO; } - // Caps Lock processing : if Caps Lock is on or Preferences.isAlphanumericalModeEnabled, temporarily disable bopomofo. + // Caps Lock processing: if Caps Lock is on or Preferences.isAlphanumericalModeEnabled, temporarily disable bopomofo. + // Also: Alphanumerical mode processing. if ([input isBackSpace] || [input isEnter] || [input isAbsorbedArrowKey] || [input isExtraChooseCandidateKey] || [input isExtraChooseCandidateKeyReverse] || [input isCursorForward] || [input isCursorBackward]) { // do nothing if backspace is pressed -- we ignore the key - } else if ([input isCapsLockOn] || Preferences.isAlphanumericalModeEnabled) { + } else if (Preferences.isAlphanumericalModeEnabled || [input isCapsLockOn]) { // process all possible combination, we hope. [self clear]; InputStateEmpty *emptyState = [[InputStateEmpty alloc] init]; stateCallback(emptyState); - // first commit everything in the buffer. - if ([input isShiftHold]) { - return NO; + // Non-Dynamic Keyboard Layouts Only: When shift is pressed, don't do further processing, since it outputs capital letter anyway. + if ((![Preferences.basisKeyboardLayout isEqual: @"com.apple.keylayout.ZhuyinBopomofo"] + && ![Preferences.basisKeyboardLayout isEqual: @"com.apple.keylayout.ZhuyinEten"]) + || [input isCapsLockOn]){ + if ([input isShiftHold]) { + return NO; + } } // if ASCII but not printable, don't use insertText:replacementRange: as many apps don't handle non-ASCII char insertions. @@ -291,10 +296,11 @@ static NSString *const kGraphVizOutputfile = @"/tmp/vChewing-visualization.dot"; return NO; } - // when shift is pressed, don't do further processing, since it outputs capital letter anyway. + // commit everything in the buffer. InputStateCommitting *committingState = [[InputStateCommitting alloc] initWithPoppedText:[input.inputText lowercaseString]]; stateCallback(committingState); stateCallback(emptyState); + return YES; }