Fix incorrect unprintable ASCII handling (#139)

When Caps Lock is on and when the character code is not printable, we
should simply reject handling such character instead of absorbing it and
inserting the character to the client buffer--not all apps handle those
insertions.
This commit is contained in:
ovadmin 2018-06-25 01:08:16 +08:00 committed by Mengjuei
parent 320bf482b1
commit 8ec0e28a29
1 changed files with 5 additions and 0 deletions

View File

@ -593,6 +593,11 @@ public:
return NO;
}
// if ASCII but not printable, don't use insertText:replacementRange: as many apps don't handle non-ASCII char insertions.
if (charCode < 0x80 && !isprint(charCode)) {
return NO;
}
// when shift is pressed, don't do further processing, since it outputs capital letter anyway.
NSString *popedText = [inputText lowercaseString];
[client insertText:popedText replacementRange:NSMakeRange(NSNotFound, NSNotFound)];