diff --git a/Source/Headers/vChewing-Bridging-Header.h b/Source/Headers/vChewing-Bridging-Header.h index d78ca431..bd2f463e 100644 --- a/Source/Headers/vChewing-Bridging-Header.h +++ b/Source/Headers/vChewing-Bridging-Header.h @@ -25,3 +25,4 @@ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR TH #import "KeyHandler.h" #import "mgrLangModel.h" +#import "ObjCUtils.h" diff --git a/Source/Modules/IMEModules/ObjCUtils.h b/Source/Modules/IMEModules/ObjCUtils.h new file mode 100644 index 00000000..35b39250 --- /dev/null +++ b/Source/Modules/IMEModules/ObjCUtils.h @@ -0,0 +1,18 @@ +// +// OjbCUtils.h +// vChewing +// +// Created by ShikiSuen on 2022/3/28. +// + +#import +#import +#import "vChewing-Swift.h" + +NS_ASSUME_NONNULL_BEGIN + +@interface ObjCUtils : NSObject ++ (bool)keyboardSwitchCondition:(NSEvent *)event; +@end + +NS_ASSUME_NONNULL_END diff --git a/Source/Modules/IMEModules/ObjCUtils.m b/Source/Modules/IMEModules/ObjCUtils.m new file mode 100644 index 00000000..9563d026 --- /dev/null +++ b/Source/Modules/IMEModules/ObjCUtils.m @@ -0,0 +1,16 @@ +// +// OjbCUtils.m +// vChewing +// +// Created by ShikiSuen on 2022/3/28. +// + +#import "ObjCUtils.h" + +@implementation ObjCUtils + ++ (bool)keyboardSwitchCondition:(NSEvent *)event { + return ((event.modifierFlags & ~NSEventModifierFlagShift) || ((event.modifierFlags & NSEventModifierFlagShift) && mgrPrefs.functionKeyKeyboardLayoutOverrideIncludeShiftKey)); +} + +@end diff --git a/vChewing.xcodeproj/project.pbxproj b/vChewing.xcodeproj/project.pbxproj index 59bdecf3..e1949c2c 100644 --- a/vChewing.xcodeproj/project.pbxproj +++ b/vChewing.xcodeproj/project.pbxproj @@ -41,6 +41,7 @@ 5BBBB77627AED70B0023B93A /* MenuIcon-TCVIM.png in Resources */ = {isa = PBXBuildFile; fileRef = 5BBBB77227AED70B0023B93A /* MenuIcon-TCVIM.png */; }; 5BBBB77A27AEDC690023B93A /* clsSFX.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5BBBB77927AEDC690023B93A /* clsSFX.swift */; }; 5BC2652227E04B7E00700291 /* uninstall.sh in Resources */ = {isa = PBXBuildFile; fileRef = 5BC2652127E04B7B00700291 /* uninstall.sh */; }; + 5BCD76CF27F1484D00C41430 /* ObjCUtils.m in Sources */ = {isa = PBXBuildFile; fileRef = 5BCD76CE27F1484D00C41430 /* ObjCUtils.m */; }; 5BD05B8127B22F3C004C4F1D /* char-kanji-cns.txt in Resources */ = {isa = PBXBuildFile; fileRef = 5BD05B8027B22F3C004C4F1D /* char-kanji-cns.txt */; }; 5BD05BCA27B2A43D004C4F1D /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 6A2E40F5253A69DA00D1AE1D /* Images.xcassets */; }; 5BD05C5D27B2BBA9004C4F1D /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 5BD05C5B27B2BBA9004C4F1D /* Main.storyboard */; }; @@ -199,6 +200,8 @@ 5BBBB77927AEDC690023B93A /* clsSFX.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = clsSFX.swift; sourceTree = ""; }; 5BBD627827B6C4D900271480 /* Update-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "Update-Info.plist"; sourceTree = ""; }; 5BC2652127E04B7B00700291 /* uninstall.sh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.sh; lineEnding = 0; path = uninstall.sh; sourceTree = ""; }; + 5BCD76CD27F1484D00C41430 /* ObjCUtils.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = ObjCUtils.h; path = Source/Modules/IMEModules/ObjCUtils.h; sourceTree = SOURCE_ROOT; }; + 5BCD76CE27F1484D00C41430 /* ObjCUtils.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; name = ObjCUtils.m; path = Source/Modules/IMEModules/ObjCUtils.m; sourceTree = SOURCE_ROOT; }; 5BD05B8027B22F3C004C4F1D /* char-kanji-cns.txt */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = "char-kanji-cns.txt"; path = "Data/components/common/char-kanji-cns.txt"; sourceTree = ""; }; 5BD05BB827B2A429004C4F1D /* vChewingPhraseEditor.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = vChewingPhraseEditor.app; sourceTree = BUILT_PRODUCTS_DIR; }; 5BD05BC627B2A42A004C4F1D /* vChewingPhraseEditor.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = vChewingPhraseEditor.entitlements; sourceTree = ""; }; @@ -409,6 +412,8 @@ D4A13D5927A59D5C003BE359 /* ctlInputMethod.swift */, 5B62A33127AE792F00A19448 /* InputSourceHelper.swift */, 5B62A33527AE795800A19448 /* mgrPrefs.swift */, + 5BCD76CD27F1484D00C41430 /* ObjCUtils.h */, + 5BCD76CE27F1484D00C41430 /* ObjCUtils.m */, ); path = IMEModules; sourceTree = ""; @@ -971,6 +976,7 @@ D47D73AC27A6CAE600255A50 /* AssociatedPhrases.mm in Sources */, 5B62A34A27AE7CD900A19448 /* NotifierController.swift in Sources */, 5B11328927B94CFB00E58451 /* AppleKeyboardConverter.swift in Sources */, + 5BCD76CF27F1484D00C41430 /* ObjCUtils.m in Sources */, D41355DB278E6D17005E5CBD /* LMInstantiator.mm in Sources */, 5B62A32927AE77D100A19448 /* FSEventStreamHelper.swift in Sources */, D47F7DD3278C1263002F9DD7 /* UserOverrideModel.cpp in Sources */,