Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Manually set the automation name of the default color scheme for screen reader #14704

Merged
1 commit merged into from
Jan 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions src/cascadia/TerminalSettingsEditor/ColorSchemes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,21 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
{
_ViewModel = e.Parameter().as<Editor::ColorSchemesPageViewModel>();
_ViewModel.CurrentPage(ColorSchemesSubPage::Base);

_layoutUpdatedRevoker = LayoutUpdated(winrt::auto_revoke, [this](auto /*s*/, auto /*e*/) {
// Only let this succeed once.
_layoutUpdatedRevoker.revoke();

for (const auto scheme : _ViewModel.AllColorSchemes())
{
if (scheme.IsDefaultScheme())
{
winrt::hstring newName{ fmt::format(L"{} ({})", scheme.Name(), RS_(L"ColorScheme_DefaultTag/Text")) };
Automation::AutomationProperties::SetName(ColorSchemeListView().ContainerFromItem(scheme), newName);
break;
}
}
});
}

void ColorSchemes::AddNew_Click(const IInspectable& /*sender*/, const RoutedEventArgs& /*e*/)
Expand Down
4 changes: 4 additions & 0 deletions src/cascadia/TerminalSettingsEditor/ColorSchemes.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
{
struct ColorSchemes : public HasScrollViewer<ColorSchemes>, ColorSchemesT<ColorSchemes>
{
public:
ColorSchemes();

void OnNavigatedTo(const winrt::Windows::UI::Xaml::Navigation::NavigationEventArgs& e);
Expand All @@ -25,6 +26,9 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
WINRT_OBSERVABLE_PROPERTY(Editor::ColorSchemesPageViewModel, ViewModel, _PropertyChangedHandlers, nullptr);

WINRT_CALLBACK(PropertyChanged, Windows::UI::Xaml::Data::PropertyChangedEventHandler);

private:
winrt::Windows::UI::Xaml::FrameworkElement::LayoutUpdated_revoker _layoutUpdatedRevoker;
};
}

Expand Down