From 7aa67dfd729aba3ad23c06de7c628b4e7f43566b Mon Sep 17 00:00:00 2001 From: Dong Yuwei Date: Tue, 12 Apr 2022 14:41:58 +0800 Subject: [PATCH] fix issues/102 --- src/AnnotationWinController.m | 6 +++--- src/InputController.mm | 9 ++++++--- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/src/AnnotationWinController.m b/src/AnnotationWinController.m index 9a8c184..8ad78e4 100644 --- a/src/AnnotationWinController.m +++ b/src/AnnotationWinController.m @@ -18,12 +18,12 @@ + (id)sharedController { - (void)awakeFromNib { sharedController = self; self.width = 160; - //self.height = 282; - + // self.height = 282; + [self.panel orderFront:nil]; [self.panel setLevel:CGShieldingWindowLevel() + 1]; // Make sure panel can float over full screen apps -// self.panel.collectionBehavior = NSWindowCollectionBehaviorCanJoinAllSpaces; + // self.panel.collectionBehavior = NSWindowCollectionBehaviorCanJoinAllSpaces; [self.panel setStyleMask:NSWindowStyleMaskBorderless]; [self performSelector:@selector(hideWindow) withObject:nil afterDelay:0.01]; // [self showWindow:NSMakePoint(10, self.height + 10)]; //for dev debug diff --git a/src/InputController.mm b/src/InputController.mm index 2993e4a..7d53a9f 100644 --- a/src/InputController.mm +++ b/src/InputController.mm @@ -10,7 +10,8 @@ extern ConversionEngine *engine; typedef NSInteger KeyCode; -static const KeyCode KEY_RETURN = 36, KEY_SPACE = 49, KEY_DELETE = 51, KEY_ESC = 53, KEY_ARROW_DOWN = 125, KEY_ARROW_UP = 126; +static const KeyCode KEY_RETURN = 36, KEY_SPACE = 49, KEY_DELETE = 51, KEY_ESC = 53, KEY_ARROW_DOWN = 125, KEY_ARROW_UP = 126, + KEY_RIGHT_SHIFT = 60; @implementation InputController @@ -23,12 +24,14 @@ - (BOOL)handleEvent:(NSEvent *)event client:(id)sender { bool handled = NO; switch ([event type]) { case NSEventTypeFlagsChanged: + // NSLog(@"hallelujah event modifierFlags %lu, event keyCode: %@", (unsigned long)[event modifierFlags], [event keyCode]); + if (_lastEventTypes[1] == NSEventTypeFlagsChanged && _lastModifiers[1] == modifiers) { return YES; } if (modifiers == 0 && _lastEventTypes[1] == NSEventTypeFlagsChanged && _lastModifiers[1] == NSEventModifierFlagShift && - !(_lastModifiers[0] & NSEventModifierFlagShift)) { + [event keyCode] == KEY_RIGHT_SHIFT && !(_lastModifiers[0] & NSEventModifierFlagShift)) { _defaultEnglishMode = !_defaultEnglishMode; if (_defaultEnglishMode) { @@ -304,7 +307,7 @@ - (void)_updateComposedBuffer:(NSAttributedString *)candidateString { - (void)activateServer:(id)sender { [sender overrideKeyboardWithKeyboardNamed:@"com.apple.keylayout.US"]; - + if (_annotationWin == nil) { _annotationWin = [AnnotationWinController sharedController]; }