Handle Shift with function key layout overrides.
This commit is contained in:
parent
a2ea20306c
commit
d4730068fa
|
@ -68,6 +68,7 @@ static const NSInteger kMaxComposingBufferSize = 20;
|
||||||
static NSString *const kKeyboardLayoutPreferenceKey = @"KeyboardLayout";
|
static NSString *const kKeyboardLayoutPreferenceKey = @"KeyboardLayout";
|
||||||
static NSString *const kBasisKeyboardLayoutPreferenceKey = @"BasisKeyboardLayout"; // alphanumeric ("ASCII") input basis
|
static NSString *const kBasisKeyboardLayoutPreferenceKey = @"BasisKeyboardLayout"; // alphanumeric ("ASCII") input basis
|
||||||
static NSString *const kFunctionKeyKeyboardLayoutPreferenceKey = @"FunctionKeyKeyboardLayout"; // alphanumeric ("ASCII") input basis
|
static NSString *const kFunctionKeyKeyboardLayoutPreferenceKey = @"FunctionKeyKeyboardLayout"; // alphanumeric ("ASCII") input basis
|
||||||
|
static NSString *const kFunctionKeyKeyboardLayoutOverrideIncludeShiftKey = @"FunctionKeyKeyboardLayoutOverrideIncludeShift"; // whether include shift
|
||||||
static NSString *const kCandidateListTextSizeKey = @"CandidateListTextSize";
|
static NSString *const kCandidateListTextSizeKey = @"CandidateListTextSize";
|
||||||
static NSString *const kSelectPhraseAfterCursorAsCandidatePreferenceKey = @"SelectPhraseAfterCursorAsCandidate";
|
static NSString *const kSelectPhraseAfterCursorAsCandidatePreferenceKey = @"SelectPhraseAfterCursorAsCandidate";
|
||||||
static NSString *const kUseHorizontalCandidateListPreferenceKey = @"UseHorizontalCandidateList";
|
static NSString *const kUseHorizontalCandidateListPreferenceKey = @"UseHorizontalCandidateList";
|
||||||
|
@ -662,15 +663,17 @@ public:
|
||||||
{
|
{
|
||||||
if ([event type] == NSFlagsChanged) {
|
if ([event type] == NSFlagsChanged) {
|
||||||
// function key pressed
|
// function key pressed
|
||||||
if ([event modifierFlags]) {
|
BOOL includeShift = [[NSUserDefaults standardUserDefaults] boolForKey:kFunctionKeyKeyboardLayoutOverrideIncludeShiftKey];
|
||||||
|
if (([event modifierFlags] & ~NSShiftKeyMask) || (([event modifierFlags] & NSShiftKeyMask) && includeShift)) {
|
||||||
NSString *functionKeyKeyboardLayoutID = [[NSUserDefaults standardUserDefaults] stringForKey:kFunctionKeyKeyboardLayoutPreferenceKey];
|
NSString *functionKeyKeyboardLayoutID = [[NSUserDefaults standardUserDefaults] stringForKey:kFunctionKeyKeyboardLayoutPreferenceKey];
|
||||||
if (!functionKeyKeyboardLayoutID) {
|
if (!functionKeyKeyboardLayoutID) {
|
||||||
functionKeyKeyboardLayoutID = @"com.apple.keylayout.US";
|
functionKeyKeyboardLayoutID = @"com.apple.keylayout.US";
|
||||||
}
|
}
|
||||||
|
|
||||||
[client overrideKeyboardWithKeyboardNamed:functionKeyKeyboardLayoutID];
|
[client overrideKeyboardWithKeyboardNamed:functionKeyKeyboardLayoutID];
|
||||||
|
return NO;
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
// reset when function key is released
|
// reset when function key is released
|
||||||
NSString *basisKeyboardLayoutID = [[NSUserDefaults standardUserDefaults] stringForKey:kBasisKeyboardLayoutPreferenceKey];
|
NSString *basisKeyboardLayoutID = [[NSUserDefaults standardUserDefaults] stringForKey:kBasisKeyboardLayoutPreferenceKey];
|
||||||
if (!basisKeyboardLayoutID) {
|
if (!basisKeyboardLayoutID) {
|
||||||
|
@ -678,7 +681,6 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
[client overrideKeyboardWithKeyboardNamed:basisKeyboardLayoutID];
|
[client overrideKeyboardWithKeyboardNamed:basisKeyboardLayoutID];
|
||||||
}
|
|
||||||
return NO;
|
return NO;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue