diff --git a/src/modules/poweraccent/PowerAccent.Core/PowerAccent.cs b/src/modules/poweraccent/PowerAccent.Core/PowerAccent.cs index b7ffcbc8e7..e419bd07b7 100644 --- a/src/modules/poweraccent/PowerAccent.Core/PowerAccent.cs +++ b/src/modules/poweraccent/PowerAccent.Core/PowerAccent.cs @@ -62,7 +62,7 @@ public class PowerAccent : IDisposable private void ShowToolbar(LetterKey letterKey) { _visible = true; - _characters = WindowsFunctions.IsCapitalState() ? ToUpper(SettingsService.GetDefaultLetterKey(letterKey)) : SettingsService.GetDefaultLetterKey(letterKey); + _characters = (WindowsFunctions.IsCapsLockState() || WindowsFunctions.IsShiftState()) ? ToUpper(SettingsService.GetDefaultLetterKey(letterKey)) : SettingsService.GetDefaultLetterKey(letterKey); Task.Delay(_settingService.InputTime).ContinueWith( t => { @@ -144,16 +144,27 @@ public class PowerAccent : IDisposable } } - if (triggerKey == TriggerKey.Left && _selectedIndex > 0) + if (triggerKey == TriggerKey.Left) { --_selectedIndex; } - if (triggerKey == TriggerKey.Right && _selectedIndex < _characters.Length - 1) + if (triggerKey == TriggerKey.Right) { ++_selectedIndex; } + // Wrap around at beginning and end of _selectedIndex range + if (_selectedIndex < 0) + { + _selectedIndex = _characters.Length - 1; + } + + if (_selectedIndex > _characters.Length - 1) + { + _selectedIndex = 0; + } + OnSelectCharacter?.Invoke(_selectedIndex, _characters[_selectedIndex]); } diff --git a/src/modules/poweraccent/PowerAccent.Core/Tools/WindowsFunctions.cs b/src/modules/poweraccent/PowerAccent.Core/Tools/WindowsFunctions.cs index 21f7a44c86..ccecc2ac3e 100644 --- a/src/modules/poweraccent/PowerAccent.Core/Tools/WindowsFunctions.cs +++ b/src/modules/poweraccent/PowerAccent.Core/Tools/WindowsFunctions.cs @@ -70,10 +70,15 @@ internal static class WindowsFunctions return (monitorInfo.rcWork.Location, monitorInfo.rcWork.Size, dpi); } - public static bool IsCapitalState() + public static bool IsCapsLockState() { var capital = User32.GetKeyState((int)User32.VK.VK_CAPITAL); + return capital != 0; + } + + public static bool IsShiftState() + { var shift = User32.GetKeyState((int)User32.VK.VK_SHIFT); - return capital != 0 || shift < 0; + return shift < 0; } }