Skip to content

Commit 82fea7e

Browse files
authored
[Quick Accent]Wrap Quick Accent toolbar selection (#20320)
* Wrap Quick Accent toolbar selection Wraps _selectionIndex at beginning and end of range. * Holding Shift + Space moves _selectedIndex backwards Moves toolbar selection from right to left when Shift key is held. * Fix formatting and typos * Change EOL of files to LF Changes PowerAccent.cs and WindowFunctions.cs back from CRLF to LF * Rename IsCapitalState() to IsCapsLockState() * Correct Logical Mistake (&& -> ||) * Removed backward movement when holding Shift
1 parent 08be4ab commit 82fea7e

File tree

2 files changed

+21
-5
lines changed

2 files changed

+21
-5
lines changed

src/modules/poweraccent/PowerAccent.Core/PowerAccent.cs

+14-3
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ private void SetEvents()
6262
private void ShowToolbar(LetterKey letterKey)
6363
{
6464
_visible = true;
65-
_characters = WindowsFunctions.IsCapitalState() ? ToUpper(SettingsService.GetDefaultLetterKey(letterKey)) : SettingsService.GetDefaultLetterKey(letterKey);
65+
_characters = (WindowsFunctions.IsCapsLockState() || WindowsFunctions.IsShiftState()) ? ToUpper(SettingsService.GetDefaultLetterKey(letterKey)) : SettingsService.GetDefaultLetterKey(letterKey);
6666
Task.Delay(_settingService.InputTime).ContinueWith(
6767
t =>
6868
{
@@ -144,16 +144,27 @@ private void ProcessNextChar(TriggerKey triggerKey)
144144
}
145145
}
146146

147-
if (triggerKey == TriggerKey.Left && _selectedIndex > 0)
147+
if (triggerKey == TriggerKey.Left)
148148
{
149149
--_selectedIndex;
150150
}
151151

152-
if (triggerKey == TriggerKey.Right && _selectedIndex < _characters.Length - 1)
152+
if (triggerKey == TriggerKey.Right)
153153
{
154154
++_selectedIndex;
155155
}
156156

157+
// Wrap around at beginning and end of _selectedIndex range
158+
if (_selectedIndex < 0)
159+
{
160+
_selectedIndex = _characters.Length - 1;
161+
}
162+
163+
if (_selectedIndex > _characters.Length - 1)
164+
{
165+
_selectedIndex = 0;
166+
}
167+
157168
OnSelectCharacter?.Invoke(_selectedIndex, _characters[_selectedIndex]);
158169
}
159170

src/modules/poweraccent/PowerAccent.Core/Tools/WindowsFunctions.cs

+7-2
Original file line numberDiff line numberDiff line change
@@ -70,10 +70,15 @@ public static (Point Location, Size Size, double Dpi) GetActiveDisplay()
7070
return (monitorInfo.rcWork.Location, monitorInfo.rcWork.Size, dpi);
7171
}
7272

73-
public static bool IsCapitalState()
73+
public static bool IsCapsLockState()
7474
{
7575
var capital = User32.GetKeyState((int)User32.VK.VK_CAPITAL);
76+
return capital != 0;
77+
}
78+
79+
public static bool IsShiftState()
80+
{
7681
var shift = User32.GetKeyState((int)User32.VK.VK_SHIFT);
77-
return capital != 0 || shift < 0;
82+
return shift < 0;
7883
}
7984
}

0 commit comments

Comments
 (0)