mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-02-24 04:00:02 +01:00
Move Focus to Type button in new row on Adding a remap (#7586)
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -13,6 +13,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;
|
||||
@@ -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
|
||||
|
||||
@@ -124,6 +124,7 @@
|
||||
<ClCompile Include="ShortcutControl.cpp" />
|
||||
<ClCompile Include="SingleKeyRemapControl.cpp" />
|
||||
<ClCompile Include="Styles.cpp" />
|
||||
<ClCompile Include="UIHelpers.cpp" />
|
||||
<ClCompile Include="XamlBridge.cpp" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
@@ -137,6 +138,7 @@
|
||||
<ClInclude Include="pch.h" />
|
||||
<ClInclude Include="ShortcutControl.h" />
|
||||
<ClInclude Include="SingleKeyRemapControl.h" />
|
||||
<ClInclude Include="UIHelpers.h" />
|
||||
<ClInclude Include="XamlBridge.h" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
|
||||
@@ -34,6 +34,9 @@
|
||||
<ClCompile Include="BufferValidationHelpers.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="UIHelpers.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="Dialog.h">
|
||||
@@ -69,6 +72,9 @@
|
||||
<ClInclude Include="BufferValidationHelpers.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="UIHelpers.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Filter Include="Source Files">
|
||||
|
||||
18
src/modules/keyboardmanager/ui/UIHelpers.cpp
Normal file
18
src/modules/keyboardmanager/ui/UIHelpers.cpp
Normal file
@@ -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<StackPanel>();
|
||||
|
||||
// Type button is the first child in the StackPanel
|
||||
Button firstTypeButtonInLastRow = firstElementInLastRow.Children().GetAt(0).as<Button>();
|
||||
|
||||
// Set programmatic focus on the button
|
||||
firstTypeButtonInLastRow.Focus(FocusState::Programmatic);
|
||||
}
|
||||
}
|
||||
8
src/modules/keyboardmanager/ui/UIHelpers.h
Normal file
8
src/modules/keyboardmanager/ui/UIHelpers.h
Normal file
@@ -0,0 +1,8 @@
|
||||
#pragma once
|
||||
|
||||
// This namespace contains UI methods that are to be used for both KBM windows
|
||||
namespace UIHelpers
|
||||
{
|
||||
// This method sets focus to the first Type button on the last row of the Grid
|
||||
void SetFocusOnTypeButtonInLastRow(Grid& parent, long colCount);
|
||||
}
|
||||
Reference in New Issue
Block a user