mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-08 04:07:40 +02:00
Fix KBM Accessibility issues (#6379)
* Added an accessible name for the combo box * Add name for the type shortcut button * Add accessible name for the add new remapping button in both key remapping as well as shortcut remapping windows * Set accessible names for the delete button * Set the accessible name to the remapped to icon * Fix the font icon issue faced while using narrator * Fix accessible name for Add shortcut remapping button * Set the accessible name for the target app text box when it loses focus * fix comment
This commit is contained in:
@@ -264,4 +264,22 @@
|
|||||||
<data name="ErrorMessage_Default" xml:space="preserve">
|
<data name="ErrorMessage_Default" xml:space="preserve">
|
||||||
<value>Unexpected error</value>
|
<value>Unexpected error</value>
|
||||||
</data>
|
</data>
|
||||||
|
<data name="Key_DropDown_Combobox" xml:space="preserve">
|
||||||
|
<value>Key Drop Down</value>
|
||||||
|
</data>
|
||||||
|
<data name="Add_Key_Remap_Button" xml:space="preserve">
|
||||||
|
<value>Add Key Remap</value>
|
||||||
|
</data>
|
||||||
|
<data name="Add_Shortcut_Button" xml:space="preserve">
|
||||||
|
<value>Add Shortcut Remapping</value>
|
||||||
|
</data>
|
||||||
|
<data name="Delete_Remapping_Button" xml:space="preserve">
|
||||||
|
<value>Delete Remapping</value>
|
||||||
|
</data>
|
||||||
|
<data name="Remapped_To" xml:space="preserve">
|
||||||
|
<value>Remapped To</value>
|
||||||
|
</data>
|
||||||
|
<data name="Target_Application" xml:space="preserve">
|
||||||
|
<value>For Target Application </value>
|
||||||
|
</data>
|
||||||
</root>
|
</root>
|
||||||
@@ -299,6 +299,8 @@ void createEditKeyboardWindow(HINSTANCE hInst, KeyboardManagerState& keyboardMan
|
|||||||
// Whenever a remap is added move to the bottom of the screen
|
// Whenever a remap is added move to the bottom of the screen
|
||||||
scrollViewer.ChangeView(nullptr, scrollViewer.ScrollableHeight(), nullptr);
|
scrollViewer.ChangeView(nullptr, scrollViewer.ScrollableHeight(), nullptr);
|
||||||
});
|
});
|
||||||
|
// Set accessible name for the addRemapKey button
|
||||||
|
addRemapKey.SetValue(Automation::AutomationProperties::NameProperty(), box_value(GET_RESOURCE_STRING(IDS_ADD_KEY_REMAP_BUTTON)));
|
||||||
|
|
||||||
StackPanel mappingsPanel;
|
StackPanel mappingsPanel;
|
||||||
mappingsPanel.Children().Append(keyRemapInfoHeader);
|
mappingsPanel.Children().Append(keyRemapInfoHeader);
|
||||||
|
|||||||
@@ -283,6 +283,8 @@ void createEditShortcutsWindow(HINSTANCE hInst, KeyboardManagerState& keyboardMa
|
|||||||
// Whenever a remap is added move to the bottom of the screen
|
// Whenever a remap is added move to the bottom of the screen
|
||||||
scrollViewer.ChangeView(nullptr, scrollViewer.ScrollableHeight(), nullptr);
|
scrollViewer.ChangeView(nullptr, scrollViewer.ScrollableHeight(), nullptr);
|
||||||
});
|
});
|
||||||
|
// Set accessible name for the add shortcut button
|
||||||
|
addShortcut.SetValue(Automation::AutomationProperties::NameProperty(), box_value(GET_RESOURCE_STRING(IDS_ADD_SHORTCUT_BUTTON)));
|
||||||
|
|
||||||
StackPanel mappingsPanel;
|
StackPanel mappingsPanel;
|
||||||
mappingsPanel.Children().Append(shortcutRemapInfoHeader);
|
mappingsPanel.Children().Append(shortcutRemapInfoHeader);
|
||||||
|
|||||||
@@ -36,6 +36,8 @@ void KeyDropDownControl::SetDefaultProperties(bool isShortcut)
|
|||||||
// Attach flyout to the drop down
|
// Attach flyout to the drop down
|
||||||
warningFlyout.as<Flyout>().Content(warningMessage.as<TextBlock>());
|
warningFlyout.as<Flyout>().Content(warningMessage.as<TextBlock>());
|
||||||
dropDown.as<ComboBox>().ContextFlyout().SetAttachedFlyout((FrameworkElement)dropDown.as<ComboBox>(), warningFlyout.as<Flyout>());
|
dropDown.as<ComboBox>().ContextFlyout().SetAttachedFlyout((FrameworkElement)dropDown.as<ComboBox>(), warningFlyout.as<Flyout>());
|
||||||
|
// To set the accessible name of the combo-box
|
||||||
|
dropDown.as<ComboBox>().SetValue(Automation::AutomationProperties::NameProperty(), box_value(GET_RESOURCE_STRING(IDS_KEY_DROPDOWN_COMBOBOX)));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Function to check if the layout has changed and accordingly update the drop down list
|
// Function to check if the layout has changed and accordingly update the drop down list
|
||||||
|
|||||||
@@ -30,6 +30,8 @@ ShortcutControl::ShortcutControl(Grid table, const int colIndex, TextBox targetA
|
|||||||
// Using the XamlRoot of the typeShortcut to get the root of the XAML host
|
// Using the XamlRoot of the typeShortcut to get the root of the XAML host
|
||||||
createDetectShortcutWindow(sender, sender.as<Button>().XamlRoot(), *keyboardManagerState, colIndex, table, keyDropDownControlObjects, shortcutControlLayout.as<StackPanel>(), targetApp, isHybridControl, false, EditShortcutsWindowHandle, shortcutRemapBuffer);
|
createDetectShortcutWindow(sender, sender.as<Button>().XamlRoot(), *keyboardManagerState, colIndex, table, keyDropDownControlObjects, shortcutControlLayout.as<StackPanel>(), targetApp, isHybridControl, false, EditShortcutsWindowHandle, shortcutRemapBuffer);
|
||||||
});
|
});
|
||||||
|
// Set an accessible name for the type shortcut button
|
||||||
|
typeShortcut.as<Button>().SetValue(Automation::AutomationProperties::NameProperty(), box_value(GET_RESOURCE_STRING(IDS_TYPE_BUTTON)));
|
||||||
|
|
||||||
shortcutControlLayout.as<StackPanel>().Margin({ 0, 0, 0, 10 });
|
shortcutControlLayout.as<StackPanel>().Margin({ 0, 0, 0, 10 });
|
||||||
shortcutControlLayout.as<StackPanel>().Spacing(KeyboardManagerConstants::ShortcutTableDropDownSpacing);
|
shortcutControlLayout.as<StackPanel>().Spacing(KeyboardManagerConstants::ShortcutTableDropDownSpacing);
|
||||||
@@ -40,6 +42,18 @@ ShortcutControl::ShortcutControl(Grid table, const int colIndex, TextBox targetA
|
|||||||
shortcutControlLayout.as<StackPanel>().UpdateLayout();
|
shortcutControlLayout.as<StackPanel>().UpdateLayout();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Function to set the accessible name of the target App text box
|
||||||
|
void ShortcutControl::SetAccessibleNameForTextBox(TextBox targetAppTextBox)
|
||||||
|
{
|
||||||
|
// To set the accessible name of the target App text box by adding the string `All Apps` if the text box is empty, if not the application name is read by narrator.
|
||||||
|
std::wstring targetAppTextBoxAccessibleName = GET_RESOURCE_STRING(IDS_TARGET_APPLICATION);
|
||||||
|
if (targetAppTextBox.Text() == L"")
|
||||||
|
{
|
||||||
|
targetAppTextBoxAccessibleName += GET_RESOURCE_STRING(IDS_EDITSHORTCUTS_ALLAPPS);
|
||||||
|
}
|
||||||
|
targetAppTextBox.SetValue(Automation::AutomationProperties::NameProperty(), box_value(targetAppTextBoxAccessibleName));
|
||||||
|
}
|
||||||
|
|
||||||
// Function to add a new row to the shortcut table. If the originalKeys and newKeys args are provided, then the displayed shortcuts are set to those values.
|
// Function to add a new row to the shortcut table. If the originalKeys and newKeys args are provided, then the displayed shortcuts are set to those values.
|
||||||
void ShortcutControl::AddNewShortcutControlRow(Grid& parent, std::vector<std::vector<std::unique_ptr<ShortcutControl>>>& keyboardRemapControlObjects, const Shortcut& originalKeys, const std::variant<DWORD, Shortcut>& newKeys, const std::wstring& targetAppName)
|
void ShortcutControl::AddNewShortcutControlRow(Grid& parent, std::vector<std::vector<std::unique_ptr<ShortcutControl>>>& keyboardRemapControlObjects, const Shortcut& originalKeys, const std::variant<DWORD, Shortcut>& newKeys, const std::wstring& targetAppName)
|
||||||
{
|
{
|
||||||
@@ -71,6 +85,8 @@ void ShortcutControl::AddNewShortcutControlRow(Grid& parent, std::vector<std::ve
|
|||||||
parent.SetRow(arrowIcon, parent.RowDefinitions().Size() - 1);
|
parent.SetRow(arrowIcon, parent.RowDefinitions().Size() - 1);
|
||||||
parent.Children().Append(arrowIcon);
|
parent.Children().Append(arrowIcon);
|
||||||
|
|
||||||
|
// To set the accessible name of the arrow icon by setting the accessible name of the remapped shortcut
|
||||||
|
keyboardRemapControlObjects[keyboardRemapControlObjects.size() - 1][1]->getShortcutControl().SetValue(Automation::AutomationProperties::NameProperty(), box_value(GET_RESOURCE_STRING(IDS_REMAPPED_TO)));
|
||||||
// ShortcutControl for the new shortcut
|
// ShortcutControl for the new shortcut
|
||||||
parent.Children().Append(keyboardRemapControlObjects[keyboardRemapControlObjects.size() - 1][1]->getShortcutControl());
|
parent.Children().Append(keyboardRemapControlObjects[keyboardRemapControlObjects.size() - 1][1]->getShortcutControl());
|
||||||
|
|
||||||
@@ -80,6 +96,8 @@ void ShortcutControl::AddNewShortcutControlRow(Grid& parent, std::vector<std::ve
|
|||||||
targetAppTextBox.HorizontalAlignment(HorizontalAlignment::Center);
|
targetAppTextBox.HorizontalAlignment(HorizontalAlignment::Center);
|
||||||
targetAppTextBox.PlaceholderText(KeyboardManagerConstants::DefaultAppName);
|
targetAppTextBox.PlaceholderText(KeyboardManagerConstants::DefaultAppName);
|
||||||
targetAppTextBox.Text(targetAppName);
|
targetAppTextBox.Text(targetAppName);
|
||||||
|
// Initialize the accessible name of the target app text box
|
||||||
|
ShortcutControl::SetAccessibleNameForTextBox(targetAppTextBox);
|
||||||
|
|
||||||
// LostFocus handler will be called whenever text is updated by a user and then they click something else or tab to another control. Does not get called if Text is updated while the TextBox isn't in focus (i.e. from code)
|
// LostFocus handler will be called whenever text is updated by a user and then they click something else or tab to another control. Does not get called if Text is updated while the TextBox isn't in focus (i.e. from code)
|
||||||
targetAppTextBox.LostFocus([&keyboardRemapControlObjects, parent, targetAppTextBox](auto const& sender, auto const& e) {
|
targetAppTextBox.LostFocus([&keyboardRemapControlObjects, parent, targetAppTextBox](auto const& sender, auto const& e) {
|
||||||
@@ -124,6 +142,9 @@ void ShortcutControl::AddNewShortcutControlRow(Grid& parent, std::vector<std::ve
|
|||||||
{
|
{
|
||||||
shortcutRemapBuffer[rowIndex].second = targetAppTextBox.Text().c_str();
|
shortcutRemapBuffer[rowIndex].second = targetAppTextBox.Text().c_str();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// To set the accessibile name of the target app text box when focus is lost
|
||||||
|
ShortcutControl::SetAccessibleNameForTextBox(targetAppTextBox);
|
||||||
});
|
});
|
||||||
|
|
||||||
parent.SetColumn(targetAppTextBox, KeyboardManagerConstants::ShortcutTableTargetAppColIndex);
|
parent.SetColumn(targetAppTextBox, KeyboardManagerConstants::ShortcutTableTargetAppColIndex);
|
||||||
@@ -166,6 +187,8 @@ void ShortcutControl::AddNewShortcutControlRow(Grid& parent, std::vector<std::ve
|
|||||||
// delete the ShortcutControl objects so that they get destructed
|
// delete the ShortcutControl objects so that they get destructed
|
||||||
keyboardRemapControlObjects.erase(keyboardRemapControlObjects.begin() + bufferIndex);
|
keyboardRemapControlObjects.erase(keyboardRemapControlObjects.begin() + bufferIndex);
|
||||||
});
|
});
|
||||||
|
// To set the accessible name of the delete button
|
||||||
|
deleteShortcut.SetValue(Automation::AutomationProperties::NameProperty(), box_value(GET_RESOURCE_STRING(IDS_DELETE_REMAPPING_BUTTON)));
|
||||||
parent.SetColumn(deleteShortcut, KeyboardManagerConstants::ShortcutTableRemoveColIndex);
|
parent.SetColumn(deleteShortcut, KeyboardManagerConstants::ShortcutTableRemoveColIndex);
|
||||||
parent.SetRow(deleteShortcut, parent.RowDefinitions().Size() - 1);
|
parent.SetRow(deleteShortcut, parent.RowDefinitions().Size() - 1);
|
||||||
parent.Children().Append(deleteShortcut);
|
parent.Children().Append(deleteShortcut);
|
||||||
|
|||||||
@@ -27,6 +27,9 @@ private:
|
|||||||
// StackPanel to parent the above controls
|
// StackPanel to parent the above controls
|
||||||
winrt::Windows::Foundation::IInspectable shortcutControlLayout;
|
winrt::Windows::Foundation::IInspectable shortcutControlLayout;
|
||||||
|
|
||||||
|
// Function to set the accessible name of the target app text box
|
||||||
|
static void SetAccessibleNameForTextBox(TextBox targetAppTextBox);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
// Handle to the current Edit Shortcuts Window
|
// Handle to the current Edit Shortcuts Window
|
||||||
static HWND EditShortcutsWindowHandle;
|
static HWND EditShortcutsWindowHandle;
|
||||||
|
|||||||
@@ -90,6 +90,8 @@ void SingleKeyRemapControl::AddNewControlKeyRemapRow(Grid& parent, std::vector<s
|
|||||||
parent.SetRow(arrowIcon, parent.RowDefinitions().Size() - 1);
|
parent.SetRow(arrowIcon, parent.RowDefinitions().Size() - 1);
|
||||||
parent.Children().Append(arrowIcon);
|
parent.Children().Append(arrowIcon);
|
||||||
|
|
||||||
|
// To set the accessible name of the arrow icon by setting the accessible name of the remapped key
|
||||||
|
keyboardRemapControlObjects[keyboardRemapControlObjects.size() - 1][1]->getSingleKeyRemapControl().SetValue(Automation::AutomationProperties::NameProperty(), box_value(GET_RESOURCE_STRING(IDS_REMAPPED_TO)));
|
||||||
// SingleKeyRemapControl for the new remap key
|
// SingleKeyRemapControl for the new remap key
|
||||||
parent.Children().Append(keyboardRemapControlObjects[keyboardRemapControlObjects.size() - 1][1]->getSingleKeyRemapControl());
|
parent.Children().Append(keyboardRemapControlObjects[keyboardRemapControlObjects.size() - 1][1]->getSingleKeyRemapControl());
|
||||||
|
|
||||||
@@ -159,6 +161,8 @@ void SingleKeyRemapControl::AddNewControlKeyRemapRow(Grid& parent, std::vector<s
|
|||||||
// delete the SingleKeyRemapControl objects so that they get destructed
|
// delete the SingleKeyRemapControl objects so that they get destructed
|
||||||
keyboardRemapControlObjects.erase(keyboardRemapControlObjects.begin() + bufferIndex);
|
keyboardRemapControlObjects.erase(keyboardRemapControlObjects.begin() + bufferIndex);
|
||||||
});
|
});
|
||||||
|
// To set the accessible name of the delete button
|
||||||
|
deleteRemapKeys.SetValue(Automation::AutomationProperties::NameProperty(), box_value(GET_RESOURCE_STRING(IDS_DELETE_REMAPPING_BUTTON)));
|
||||||
parent.SetColumn(deleteRemapKeys, KeyboardManagerConstants::RemapTableRemoveColIndex);
|
parent.SetColumn(deleteRemapKeys, KeyboardManagerConstants::RemapTableRemoveColIndex);
|
||||||
parent.SetRow(deleteRemapKeys, parent.RowDefinitions().Size() - 1);
|
parent.SetRow(deleteRemapKeys, parent.RowDefinitions().Size() - 1);
|
||||||
parent.Children().Append(deleteRemapKeys);
|
parent.Children().Append(deleteRemapKeys);
|
||||||
|
|||||||
@@ -8,6 +8,7 @@
|
|||||||
#include <winrt/Windows.system.h>
|
#include <winrt/Windows.system.h>
|
||||||
#include <winrt/windows.ui.xaml.hosting.h>
|
#include <winrt/windows.ui.xaml.hosting.h>
|
||||||
#include <windows.ui.xaml.hosting.desktopwindowxamlsource.h>
|
#include <windows.ui.xaml.hosting.desktopwindowxamlsource.h>
|
||||||
|
#include <winrt/Windows.UI.Xaml.Automation.h>
|
||||||
#include <winrt/windows.ui.xaml.controls.h>
|
#include <winrt/windows.ui.xaml.controls.h>
|
||||||
#include <winrt/Windows.ui.xaml.media.h>
|
#include <winrt/Windows.ui.xaml.media.h>
|
||||||
#include <winrt/Windows.Foundation.Collections.h>
|
#include <winrt/Windows.Foundation.Collections.h>
|
||||||
|
|||||||
Reference in New Issue
Block a user