diff --git a/src/modules/keyboardmanager/ui/EditKeyboardWindow.cpp b/src/modules/keyboardmanager/ui/EditKeyboardWindow.cpp index 8539d99617..1c19d2d57c 100644 --- a/src/modules/keyboardmanager/ui/EditKeyboardWindow.cpp +++ b/src/modules/keyboardmanager/ui/EditKeyboardWindow.cpp @@ -15,6 +15,7 @@ #include "keyboardmanager/common/KeyboardManagerState.h" #include "common/common.h" #include "LoadingAndSavingRemappingHelper.h" +#include "UIHelpers.h" extern "C" IMAGE_DOS_HEADER __ImageBase; using namespace winrt::Windows::Foundation; @@ -304,8 +305,12 @@ void createEditKeyboardWindow(HINSTANCE hInst, KeyboardManagerState& keyboardMan addRemapKey.Margin({ 10, 10, 0, 25 }); addRemapKey.Click([&](winrt::Windows::Foundation::IInspectable const& sender, RoutedEventArgs const&) { SingleKeyRemapControl::AddNewControlKeyRemapRow(keyRemapTable, keyboardRemapControlObjects); + // Whenever a remap is added move to the bottom of the screen scrollViewer.ChangeView(nullptr, scrollViewer.ScrollableHeight(), nullptr); + + // Set focus to the first Type Button in the newly added row + UIHelpers::SetFocusOnTypeButtonInLastRow(keyRemapTable, KeyboardManagerConstants::RemapTableColCount); }); // Set accessible name for the addRemapKey button diff --git a/src/modules/keyboardmanager/ui/EditShortcutsWindow.cpp b/src/modules/keyboardmanager/ui/EditShortcutsWindow.cpp index 306cfc3005..3d48059300 100644 --- a/src/modules/keyboardmanager/ui/EditShortcutsWindow.cpp +++ b/src/modules/keyboardmanager/ui/EditShortcutsWindow.cpp @@ -13,6 +13,7 @@ #include #include "common/common.h" #include "LoadingAndSavingRemappingHelper.h" +#include "UIHelpers.h" extern "C" IMAGE_DOS_HEADER __ImageBase; using namespace winrt::Windows::Foundation; @@ -291,8 +292,12 @@ void createEditShortcutsWindow(HINSTANCE hInst, KeyboardManagerState& keyboardMa addShortcut.Margin({ 10, 0, 0, 25 }); addShortcut.Click([&](winrt::Windows::Foundation::IInspectable const& sender, RoutedEventArgs const&) { ShortcutControl::AddNewShortcutControlRow(shortcutTable, keyboardRemapControlObjects); + // Whenever a remap is added move to the bottom of the screen scrollViewer.ChangeView(nullptr, scrollViewer.ScrollableHeight(), nullptr); + + // Set focus to the first Type Button in the newly added row + UIHelpers::SetFocusOnTypeButtonInLastRow(shortcutTable, KeyboardManagerConstants::ShortcutTableColCount); }); // Set accessible name for the add shortcut button diff --git a/src/modules/keyboardmanager/ui/KeyboardManagerUI.vcxproj b/src/modules/keyboardmanager/ui/KeyboardManagerUI.vcxproj index 4610861895..66a190af1d 100644 --- a/src/modules/keyboardmanager/ui/KeyboardManagerUI.vcxproj +++ b/src/modules/keyboardmanager/ui/KeyboardManagerUI.vcxproj @@ -124,6 +124,7 @@ + @@ -137,6 +138,7 @@ + diff --git a/src/modules/keyboardmanager/ui/KeyboardManagerUI.vcxproj.filters b/src/modules/keyboardmanager/ui/KeyboardManagerUI.vcxproj.filters index 19aee28c5b..c23ccf4a3e 100644 --- a/src/modules/keyboardmanager/ui/KeyboardManagerUI.vcxproj.filters +++ b/src/modules/keyboardmanager/ui/KeyboardManagerUI.vcxproj.filters @@ -34,6 +34,9 @@ Source Files + + Source Files + @@ -69,6 +72,9 @@ Header Files + + Header Files + diff --git a/src/modules/keyboardmanager/ui/UIHelpers.cpp b/src/modules/keyboardmanager/ui/UIHelpers.cpp new file mode 100644 index 0000000000..beb9e5d1c9 --- /dev/null +++ b/src/modules/keyboardmanager/ui/UIHelpers.cpp @@ -0,0 +1,18 @@ +#include "pch.h" +#include "UIHelpers.h" + +namespace UIHelpers +{ + // This method sets focus to the first Type button on the last row of the Grid + void SetFocusOnTypeButtonInLastRow(Grid& parent, long colCount) + { + // First element in the last row (StackPanel) + StackPanel firstElementInLastRow = parent.Children().GetAt(parent.Children().Size() - colCount).as(); + + // Type button is the first child in the StackPanel + Button firstTypeButtonInLastRow = firstElementInLastRow.Children().GetAt(0).as