diff --git a/mac/Keyman4MacIM/Keyman4MacIM/OnScreenKeyboard/OSKWindowController.m b/mac/Keyman4MacIM/Keyman4MacIM/OnScreenKeyboard/OSKWindowController.m index ca4181d11c..19b7ece101 100644 --- a/mac/Keyman4MacIM/Keyman4MacIM/OnScreenKeyboard/OSKWindowController.m +++ b/mac/Keyman4MacIM/Keyman4MacIM/OnScreenKeyboard/OSKWindowController.m @@ -67,8 +67,11 @@ - (void)windowDidResize:(NSNotification *)notification { } - (void)windowWillClose:(NSNotification *)notification { + os_log_debug([KMLogs oskLog], "OSKWindowController windowWillClose"); [KMSettingsRepository.shared writeShowOskOnActivate:NO]; - os_log_debug([KMLogs oskLog], "OSKWindowController windowWillClose, updating settings writeShowOsk to NO"); + + // whenever the OSK is closed clear all of its modifier keys + [self.oskView clearOskModifiers]; } - (void)helpAction:(id)sender { diff --git a/mac/KeymanEngine4Mac/KeymanEngine4Mac/KME/OnScreenKeyboard/OSKView.h b/mac/KeymanEngine4Mac/KeymanEngine4Mac/KME/OnScreenKeyboard/OSKView.h index 082604871e..cc582eca71 100644 --- a/mac/KeymanEngine4Mac/KeymanEngine4Mac/KME/OnScreenKeyboard/OSKView.h +++ b/mac/KeymanEngine4Mac/KeymanEngine4Mac/KME/OnScreenKeyboard/OSKView.h @@ -25,6 +25,7 @@ - (void)setOskOptionState:(BOOL)oskAltState; - (void)setPhysicalControlState:(BOOL)ctrlState; - (void)setOskControlState:(BOOL)oskCtrlState; +- (void)clearOskModifiers; - (void)resetOSK; - (void)resizeOSKLayout; - (int64_t)createOskEventUserData; diff --git a/mac/KeymanEngine4Mac/KeymanEngine4Mac/KME/OnScreenKeyboard/OSKView.m b/mac/KeymanEngine4Mac/KeymanEngine4Mac/KME/OnScreenKeyboard/OSKView.m index 4bf0f6a0e8..91adf05eb7 100644 --- a/mac/KeymanEngine4Mac/KeymanEngine4Mac/KME/OnScreenKeyboard/OSKView.m +++ b/mac/KeymanEngine4Mac/KeymanEngine4Mac/KME/OnScreenKeyboard/OSKView.m @@ -427,6 +427,17 @@ - (NSArray *)oskDefaultNKeys { return _oskDefaultNKeys; } +/** + * called when closing the OSK + * when the OSK is not visible then modifier state is determined solely by the physical keyboard + */ +- (void)clearOskModifiers { + _oskShiftState = NO; + _oskOptionState = NO; + _oskControlState = NO; + [self displayKeyLabelsForLayer]; +} + - (void)resetOSK { [self setOskShiftState:NO]; [self setOskOptionState:NO];