[QuickAccent] Shift + Space to navigate backwards (#21817)

* shift space to navigate backwards

* detect shift with visible toolbar

* distinguish left/right shift

* fix
This commit is contained in:
Davide Giacometti
2022-11-17 17:16:40 +01:00
committed by GitHub
parent 5779b43c80
commit 8fb93dc6ee
4 changed files with 54 additions and 16 deletions

View File

@@ -1,4 +1,4 @@
// Copyright (c) Microsoft Corporation
// Copyright (c) Microsoft Corporation
// The Microsoft Corporation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
@@ -52,11 +52,11 @@ public class PowerAccent : IDisposable
});
}));
_keyboardListener.SetNextCharEvent(new PowerToys.PowerAccentKeyboardService.NextChar((TriggerKey triggerKey) =>
_keyboardListener.SetNextCharEvent(new PowerToys.PowerAccentKeyboardService.NextChar((TriggerKey triggerKey, bool shiftPressed) =>
{
System.Windows.Application.Current.Dispatcher.Invoke(() =>
{
ProcessNextChar(triggerKey);
ProcessNextChar(triggerKey, shiftPressed);
});
}));
@@ -106,7 +106,7 @@ public class PowerAccent : IDisposable
_visible = false;
}
private void ProcessNextChar(TriggerKey triggerKey)
private void ProcessNextChar(TriggerKey triggerKey, bool shiftPressed)
{
if (_visible && _selectedIndex == -1)
{
@@ -141,13 +141,27 @@ public class PowerAccent : IDisposable
if (triggerKey == TriggerKey.Space)
{
if (_selectedIndex < _characters.Length - 1)
if (shiftPressed)
{
++_selectedIndex;
if (_selectedIndex == 0)
{
_selectedIndex = _characters.Length - 1;
}
else
{
--_selectedIndex;
}
}
else
{
_selectedIndex = 0;
if (_selectedIndex < _characters.Length - 1)
{
++_selectedIndex;
}
else
{
_selectedIndex = 0;
}
}
}