Skip to content

Commit

Permalink
Raise notification event on delete key/shortcut button click (#12546)
Browse files Browse the repository at this point in the history
  • Loading branch information
stefansjfw committed Jul 29, 2021
1 parent 5a97db8 commit e762bfa
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -357,6 +357,9 @@
<data name="Delete_Remapping_Button" xml:space="preserve">
<value>Delete Remapping</value>
</data>
<data name="Delete_Remapping_Event" xml:space="preserve">
<value>Remapping deleted</value>
</data>
<data name="AutomationProperties_Row" xml:space="preserve">
<value>Row </value>
</data>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ void ShortcutControl::AddNewShortcutControlRow(StackPanel& parent, std::vector<s
deleteShortcut.Content(deleteSymbol);
deleteShortcut.Background(Media::SolidColorBrush(Colors::Transparent()));
deleteShortcut.HorizontalAlignment(HorizontalAlignment::Center);
deleteShortcut.Click([&, parent, row, brush](winrt::Windows::Foundation::IInspectable const& sender, RoutedEventArgs const&) {
deleteShortcut.Click([&, parent, row, brush, deleteShortcut](winrt::Windows::Foundation::IInspectable const& sender, RoutedEventArgs const&) {
Button currentButton = sender.as<Button>();
uint32_t rowIndex;
// Get index of delete button
Expand All @@ -215,6 +215,15 @@ void ShortcutControl::AddNewShortcutControlRow(StackPanel& parent, std::vector<s
UpdateAccessibleNames(sourceCol, targetCol, targetApp, delButton, i);
}

if (auto automationPeer{ Automation::Peers::FrameworkElementAutomationPeer::FromElement(deleteShortcut) })
{
automationPeer.RaiseNotificationEvent(
Automation::Peers::AutomationNotificationKind::ActionCompleted,
Automation::Peers::AutomationNotificationProcessing::ImportantMostRecent,
GET_RESOURCE_STRING(IDS_DELETE_REMAPPING_EVENT),
L"ShortcutRemappingDeletedNotificationEvent" /* unique name for this notification category */);
}

children.RemoveAt(rowIndex);
parent.UpdateLayout();
shortcutRemapBuffer.erase(shortcutRemapBuffer.begin() + rowIndex);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ void SingleKeyRemapControl::AddNewControlKeyRemapRow(StackPanel& parent, std::ve
deleteRemapKeys.Content(deleteSymbol);
deleteRemapKeys.Background(Media::SolidColorBrush(Colors::Transparent()));
deleteRemapKeys.HorizontalAlignment(HorizontalAlignment::Center);
deleteRemapKeys.Click([&, parent, row, brush](winrt::Windows::Foundation::IInspectable const& sender, RoutedEventArgs const&) {
deleteRemapKeys.Click([&, parent, row, brush, deleteRemapKeys](winrt::Windows::Foundation::IInspectable const& sender, RoutedEventArgs const&) {
uint32_t rowIndex;
// Get index of delete button
UIElementCollection children = parent.Children();
Expand All @@ -158,6 +158,15 @@ void SingleKeyRemapControl::AddNewControlKeyRemapRow(StackPanel& parent, std::ve
UpdateAccessibleNames(sourceCol, targetCol, delButton, i);
}

if (auto automationPeer{ Automation::Peers::FrameworkElementAutomationPeer::FromElement(deleteRemapKeys) })
{
automationPeer.RaiseNotificationEvent(
Automation::Peers::AutomationNotificationKind::ActionCompleted,
Automation::Peers::AutomationNotificationProcessing::ImportantMostRecent,
GET_RESOURCE_STRING(IDS_DELETE_REMAPPING_EVENT),
L"KeyRemappingDeletedNotificationEvent" /* unique name for this notification category */);
}

children.RemoveAt(rowIndex);
parent.UpdateLayout();
singleKeyRemapBuffer.erase(singleKeyRemapBuffer.begin() + rowIndex);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#pragma push_macro("GetCurrentTime")
#undef GetCurrentTime
#include <winrt/Windows.UI.Xaml.Automation.h>
#include <winrt/Windows.UI.Xaml.Automation.Peers.h>
#include <winrt/Windows.UI.Xaml.Controls.Primitives.h>
#include <winrt/Windows.UI.Xaml.Hosting.h>
#include <winrt/Windows.UI.Xaml.Interop.h>
Expand Down

0 comments on commit e762bfa

Please sign in to comment.