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.
This commit is contained in:
ShikiSuen 2022-03-01 22:18:59 +08:00
parent 4617de4096
commit 62d28574d4
1 changed files with 12 additions and 6 deletions

View File

@ -272,18 +272,23 @@ static NSString *const kGraphVizOutputfile = @"/tmp/vChewing-visualization.dot";
return NO; 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]) { 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 // 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. // process all possible combination, we hope.
[self clear]; [self clear];
InputStateEmpty *emptyState = [[InputStateEmpty alloc] init]; InputStateEmpty *emptyState = [[InputStateEmpty alloc] init];
stateCallback(emptyState); stateCallback(emptyState);
// first commit everything in the buffer. // Non-Dynamic Keyboard Layouts Only: When shift is pressed, don't do further processing, since it outputs capital letter anyway.
if ([input isShiftHold]) { if ((![Preferences.basisKeyboardLayout isEqual: @"com.apple.keylayout.ZhuyinBopomofo"]
return NO; && ![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. // 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; 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]]; InputStateCommitting *committingState = [[InputStateCommitting alloc] initWithPoppedText:[input.inputText lowercaseString]];
stateCallback(committingState); stateCallback(committingState);
stateCallback(emptyState); stateCallback(emptyState);
return YES; return YES;
} }