mirror of
https://github.com/microsoft/PowerToys.git
synced 2024-11-24 04:12:32 +08:00
[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
This commit is contained in:
parent
08be4abd56
commit
82fea7eff1
@ -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]);
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user