[broken] Add screen reader confirmation announcements to SUI

This commit is contained in:
Carlos Zamora 2024-09-11 14:51:28 -07:00
parent 6196a3d0f7
commit 540154066d
8 changed files with 47 additions and 5 deletions

View File

@ -139,7 +139,7 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
}
}
void ColorSchemeViewModel::DeleteConfirmation_Click(const IInspectable& /*sender*/, const Windows::UI::Xaml::RoutedEventArgs& /*e*/)
void ColorSchemeViewModel::RequestDeleteCurrentScheme()
{
if (const auto parentPageVM{ _parentPageVM.get() })
{

View File

@ -28,13 +28,13 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
hstring ToString();
bool RequestRename(winrt::hstring newName);
void RequestDeleteCurrentScheme();
Editor::ColorTableEntry ColorEntryAt(uint32_t index);
bool IsDefaultScheme();
void RefreshIsDefault();
bool IsEditable() const;
void DeleteConfirmation_Click(const winrt::Windows::Foundation::IInspectable& sender, const winrt::Windows::UI::Xaml::RoutedEventArgs& e);
void SetAsDefault_Click(const winrt::Windows::Foundation::IInspectable& sender, const winrt::Windows::UI::Xaml::RoutedEventArgs& e);
void Duplicate_Click(const winrt::Windows::Foundation::IInspectable& sender, const winrt::Windows::UI::Xaml::RoutedEventArgs& e);

View File

@ -25,7 +25,6 @@ namespace Microsoft.Terminal.Settings.Editor
ColorTableEntry CursorColor;
ColorTableEntry SelectionBackgroundColor;
void DeleteConfirmation_Click(IInspectable sender, Windows.UI.Xaml.RoutedEventArgs args);
void SetAsDefault_Click(IInspectable sender, Windows.UI.Xaml.RoutedEventArgs args);
void Duplicate_Click(IInspectable sender, Windows.UI.Xaml.RoutedEventArgs args);
}

View File

@ -46,12 +46,20 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
});
}
void ColorSchemes::AddNew_Click(const IInspectable& /*sender*/, const RoutedEventArgs& /*e*/)
void ColorSchemes::AddNew_Click(const IInspectable& sender, const RoutedEventArgs& /*e*/)
{
if (const auto newSchemeVM{ _ViewModel.RequestAddNew() })
{
ColorSchemeListView().SelectedItem(newSchemeVM);
_ViewModel.RequestEditSelectedScheme();
if (auto automationPeer{ Automation::Peers::FrameworkElementAutomationPeer::FromElement(sender.as<UIElement>()) })
{
automationPeer.RaiseNotificationEvent(Automation::Peers::AutomationNotificationKind::ActionCompleted,
Automation::Peers::AutomationNotificationProcessing::ImportantAll,
RS_fmt(L"ColorScheme_AddNewButton_ConfirmationMessage", newSchemeVM.Name()),
L"ColorSchemeAdded");
}
}
}

View File

@ -115,12 +115,21 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
void EditColorScheme::_RenameCurrentScheme(hstring newName)
{
const auto oldName = _ViewModel.Name();
if (_ViewModel.RequestRename(newName))
{
// update the UI
RenameErrorTip().IsOpen(false);
NameBox().Focus(FocusState::Programmatic);
if (auto automationPeer{ Automation::Peers::FrameworkElementAutomationPeer::FromElement(*this) })
{
automationPeer.RaiseNotificationEvent(Automation::Peers::AutomationNotificationKind::ActionCompleted,
Automation::Peers::AutomationNotificationProcessing::ImportantAll,
RS_fmt(L"ColorScheme_Rename_ConfirmationMessage", oldName, newName),
L"ColorSchemeAdded");
}
}
else
{
@ -132,4 +141,17 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
NameBox().SelectAll();
}
}
void EditColorScheme::DeleteConfirmation_Click(const IInspectable& /*sender*/, const RoutedEventArgs& /*e*/)
{
winrt::get_self<ColorSchemeViewModel>(_ViewModel)->RequestDeleteCurrentScheme();
if (auto automationPeer{ Automation::Peers::FrameworkElementAutomationPeer::FromElement(*this) })
{
automationPeer.RaiseNotificationEvent(Automation::Peers::AutomationNotificationKind::ActionCompleted,
Automation::Peers::AutomationNotificationProcessing::ImportantAll,
RS_fmt(L"ColorScheme_Delete_ConfirmationMessage", _ViewModel.Name()),
L"ColorSchemeDeleted");
}
}
}

View File

@ -19,6 +19,7 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
void RenameAccept_Click(const winrt::Windows::Foundation::IInspectable& sender, const winrt::Windows::UI::Xaml::RoutedEventArgs& e);
void RenameCancel_Click(const winrt::Windows::Foundation::IInspectable& sender, const winrt::Windows::UI::Xaml::RoutedEventArgs& e);
void NameBox_PreviewKeyDown(const winrt::Windows::Foundation::IInspectable& sender, const winrt::Windows::UI::Xaml::Input::KeyRoutedEventArgs& e);
void DeleteConfirmation_Click(const winrt::Windows::Foundation::IInspectable& sender, const winrt::Windows::UI::Xaml::RoutedEventArgs& e);
til::property_changed_event PropertyChanged;

View File

@ -493,7 +493,7 @@
<TextBlock x:Uid="ColorScheme_DeleteConfirmationMessage"
Style="{StaticResource CustomFlyoutTextStyle}" />
<Button x:Uid="ColorScheme_DeleteConfirmationButton"
Click="{x:Bind ViewModel.DeleteConfirmation_Click}" />
Click="DeleteConfirmation_Click" />
</StackPanel>
</Flyout>
</Button.Flyout>

View File

@ -1483,6 +1483,18 @@
<value>Add new</value>
<comment>Button label that creates a new color scheme.</comment>
</data>
<data name="ColorScheme_AddNewButton_ConfirmationMessage" xml:space="preserve">
<value>{} added</value>
<comment>{Locked="{}"} Confirmation message announced by the screen reader that the color scheme was successfully added. "{}" will be replaced with the color scheme's name.</comment>
</data>
<data name="ColorScheme_Rename_ConfirmationMessage" xml:space="preserve">
<value>{} renamed to {}</value>
<comment>{Locked="{}"} Confirmation message announced by the screen reader that the color scheme was successfully renamed. "{}" will be replaced with the color scheme's old and new name respectively.</comment>
</data>
<data name="ColorScheme_Delete_ConfirmationMessage" xml:space="preserve">
<value>{} deleted</value>
<comment>{Locked="{}"} Confirmation message announced by the screen reader that the color scheme was successfully deleted. "{}" will be replaced with the color scheme's name.</comment>
</data>
<data name="ColorScheme_DeleteButton.Text" xml:space="preserve">
<value>Delete color scheme</value>
<comment>Button label that deletes the selected color scheme.</comment>