KBM - Change behavior to hold enter to accept rather than hold and release (#2931)

* Changed to hold enter

* Changed code such that hold enter does not trigger a re-open

* Fixed tab ordering

* Changed text
This commit is contained in:
Arjun Balgovind
2020-05-13 10:13:44 -07:00
committed by GitHub
parent 01f11d94b0
commit d178fa5bdb
4 changed files with 49 additions and 35 deletions

View File

@@ -389,8 +389,8 @@ void createEditKeyboardWindow(HINSTANCE hInst, KeyboardManagerState& keyboardMan
}); });
header.Children().Append(headerText); header.Children().Append(headerText);
header.Children().Append(cancelButton);
header.Children().Append(applyButton); header.Children().Append(applyButton);
header.Children().Append(cancelButton);
// Add remap key button // Add remap key button
Windows::UI::Xaml::Controls::Button addRemapKey; Windows::UI::Xaml::Controls::Button addRemapKey;

View File

@@ -272,8 +272,8 @@ void createEditShortcutsWindow(HINSTANCE hInst, KeyboardManagerState& keyboardMa
}); });
header.Children().Append(headerText); header.Children().Append(headerText);
header.Children().Append(cancelButton);
header.Children().Append(applyButton); header.Children().Append(applyButton);
header.Children().Append(cancelButton);
// Add shortcut button // Add shortcut button
Windows::UI::Xaml::Controls::Button addShortcut; Windows::UI::Xaml::Controls::Button addShortcut;

View File

@@ -157,14 +157,14 @@ void ShortcutControl::createDetectShortcutWindow(winrt::Windows::Foundation::IIn
keyboardManagerState.ResetDetectedShortcutKey(key); keyboardManagerState.ResetDetectedShortcutKey(key);
}; };
auto onAccept = [this, auto onPressEnter = [this,
linkedShortcutStackPanel, linkedShortcutStackPanel,
detectShortcutBox, detectShortcutBox,
&keyboardManagerState, &keyboardManagerState,
&shortcutRemapBuffer, &shortcutRemapBuffer,
unregisterKeys, unregisterKeys,
colIndex, colIndex,
table] { table] {
// Save the detected shortcut in the linked text block // Save the detected shortcut in the linked text block
Shortcut detectedShortcutKeys = keyboardManagerState.GetDetectedShortcut(); Shortcut detectedShortcutKeys = keyboardManagerState.GetDetectedShortcut();
@@ -173,13 +173,23 @@ void ShortcutControl::createDetectShortcutWindow(winrt::Windows::Foundation::IIn
// The shortcut buffer gets set in this function // The shortcut buffer gets set in this function
AddShortcutToControl(detectedShortcutKeys, table, linkedShortcutStackPanel, keyboardManagerState, colIndex); AddShortcutToControl(detectedShortcutKeys, table, linkedShortcutStackPanel, keyboardManagerState, colIndex);
} }
// Hide the type shortcut UI
detectShortcutBox.Hide();
};
auto onReleaseEnter = [&keyboardManagerState,
unregisterKeys] {
// Reset the keyboard manager UI state // Reset the keyboard manager UI state
keyboardManagerState.ResetUIState(); keyboardManagerState.ResetUIState();
// Revert UI state back to Edit Shortcut window // Revert UI state back to Edit Shortcut window
keyboardManagerState.SetUIState(KeyboardManagerUIState::EditShortcutsWindowActivated, EditShortcutsWindowHandle); keyboardManagerState.SetUIState(KeyboardManagerUIState::EditShortcutsWindowActivated, EditShortcutsWindowHandle);
unregisterKeys(); unregisterKeys();
detectShortcutBox.Hide(); };
auto onAccept = [onPressEnter,
onReleaseEnter] {
onPressEnter();
onReleaseEnter();
}; };
TextBlock primaryButtonText; TextBlock primaryButtonText;
@@ -198,20 +208,17 @@ void ShortcutControl::createDetectShortcutWindow(winrt::Windows::Foundation::IIn
keyboardManagerState.RegisterKeyDelay( keyboardManagerState.RegisterKeyDelay(
VK_RETURN, VK_RETURN,
selectDetectedShortcutAndResetKeys, selectDetectedShortcutAndResetKeys,
[primaryButton, detectShortcutBox](DWORD) { [primaryButton, onPressEnter, detectShortcutBox](DWORD) {
detectShortcutBox.Dispatcher().RunAsync( detectShortcutBox.Dispatcher().RunAsync(
Windows::UI::Core::CoreDispatcherPriority::Normal, Windows::UI::Core::CoreDispatcherPriority::Normal,
[primaryButton] { [primaryButton, onPressEnter] {
// Use the base medium low brush to be consistent with the theme // Use the base medium low brush to be consistent with the theme
primaryButton.Background(Windows::UI::Xaml::Application::Current().Resources().Lookup(box_value(L"SystemControlBackgroundBaseMediumLowBrush")).as<Windows::UI::Xaml::Media::SolidColorBrush>()); primaryButton.Background(Windows::UI::Xaml::Application::Current().Resources().Lookup(box_value(L"SystemControlBackgroundBaseMediumLowBrush")).as<Windows::UI::Xaml::Media::SolidColorBrush>());
onPressEnter();
}); });
}, },
[onAccept, detectShortcutBox](DWORD) { [onReleaseEnter](DWORD) {
detectShortcutBox.Dispatcher().RunAsync( onReleaseEnter();
Windows::UI::Core::CoreDispatcherPriority::Normal,
[onAccept] {
onAccept();
});
}); });
TextBlock cancelButtonText; TextBlock cancelButtonText;
@@ -270,7 +277,7 @@ void ShortcutControl::createDetectShortcutWindow(winrt::Windows::Foundation::IIn
stackPanel.Children().Append(holdEscInfo); stackPanel.Children().Append(holdEscInfo);
TextBlock holdEnterInfo; TextBlock holdEnterInfo;
holdEnterInfo.Text(L"Hold Enter to apply"); holdEnterInfo.Text(L"Hold Enter to continue");
holdEnterInfo.FontSize(12); holdEnterInfo.FontSize(12);
holdEnterInfo.Margin({ 0, 0, 0, 0 }); holdEnterInfo.Margin({ 0, 0, 0, 0 });
stackPanel.Children().Append(holdEnterInfo); stackPanel.Children().Append(holdEnterInfo);

View File

@@ -131,11 +131,11 @@ void SingleKeyRemapControl::createDetectKeyWindow(winrt::Windows::Foundation::II
t2.detach(); t2.detach();
}; };
auto onAccept = [linkedRemapDropDown, auto onPressEnter = [linkedRemapDropDown,
detectRemapKeyBox, detectRemapKeyBox,
&keyboardManagerState, &keyboardManagerState,
&singleKeyRemapBuffer, &singleKeyRemapBuffer,
unregisterKeys] { unregisterKeys] {
// Save the detected key in the linked text block // Save the detected key in the linked text block
DWORD detectedKey = keyboardManagerState.GetDetectedSingleRemapKey(); DWORD detectedKey = keyboardManagerState.GetDetectedSingleRemapKey();
@@ -150,13 +150,23 @@ void SingleKeyRemapControl::createDetectKeyWindow(winrt::Windows::Foundation::II
linkedRemapDropDown.SelectedIndex((int32_t)std::distance(keyCodeList.begin(), it)); linkedRemapDropDown.SelectedIndex((int32_t)std::distance(keyCodeList.begin(), it));
} }
} }
// Hide the type key UI
detectRemapKeyBox.Hide();
};
auto onReleaseEnter = [&keyboardManagerState,
unregisterKeys] {
// Reset the keyboard manager UI state // Reset the keyboard manager UI state
keyboardManagerState.ResetUIState(); keyboardManagerState.ResetUIState();
// Revert UI state back to Edit Keyboard window // Revert UI state back to Edit Keyboard window
keyboardManagerState.SetUIState(KeyboardManagerUIState::EditKeyboardWindowActivated, EditKeyboardWindowHandle); keyboardManagerState.SetUIState(KeyboardManagerUIState::EditKeyboardWindowActivated, EditKeyboardWindowHandle);
unregisterKeys(); unregisterKeys();
detectRemapKeyBox.Hide(); };
auto onAccept = [onPressEnter,
onReleaseEnter] {
onPressEnter();
onReleaseEnter();
}; };
TextBlock primaryButtonText; TextBlock primaryButtonText;
@@ -173,20 +183,17 @@ void SingleKeyRemapControl::createDetectKeyWindow(winrt::Windows::Foundation::II
keyboardManagerState.RegisterKeyDelay( keyboardManagerState.RegisterKeyDelay(
VK_RETURN, VK_RETURN,
std::bind(&KeyboardManagerState::SelectDetectedRemapKey, &keyboardManagerState, std::placeholders::_1), std::bind(&KeyboardManagerState::SelectDetectedRemapKey, &keyboardManagerState, std::placeholders::_1),
[primaryButton, detectRemapKeyBox](DWORD) { [primaryButton, onPressEnter, detectRemapKeyBox](DWORD) {
detectRemapKeyBox.Dispatcher().RunAsync( detectRemapKeyBox.Dispatcher().RunAsync(
Windows::UI::Core::CoreDispatcherPriority::Normal, Windows::UI::Core::CoreDispatcherPriority::Normal,
[primaryButton] { [primaryButton, onPressEnter] {
// Use the base medium low brush to be consistent with the theme // Use the base medium low brush to be consistent with the theme
primaryButton.Background(Windows::UI::Xaml::Application::Current().Resources().Lookup(box_value(L"SystemControlBackgroundBaseMediumLowBrush")).as<Windows::UI::Xaml::Media::SolidColorBrush>()); primaryButton.Background(Windows::UI::Xaml::Application::Current().Resources().Lookup(box_value(L"SystemControlBackgroundBaseMediumLowBrush")).as<Windows::UI::Xaml::Media::SolidColorBrush>());
onPressEnter();
}); });
}, },
[onAccept, detectRemapKeyBox](DWORD) { [onReleaseEnter](DWORD) {
detectRemapKeyBox.Dispatcher().RunAsync( onReleaseEnter();
Windows::UI::Core::CoreDispatcherPriority::Normal,
[onAccept] {
onAccept();
});
}); });
TextBlock cancelButtonText; TextBlock cancelButtonText;
@@ -245,7 +252,7 @@ void SingleKeyRemapControl::createDetectKeyWindow(winrt::Windows::Foundation::II
stackPanel.Children().Append(holdEscInfo); stackPanel.Children().Append(holdEscInfo);
TextBlock holdEnterInfo; TextBlock holdEnterInfo;
holdEnterInfo.Text(L"Hold Enter to apply"); holdEnterInfo.Text(L"Hold Enter to continue");
holdEnterInfo.FontSize(12); holdEnterInfo.FontSize(12);
holdEnterInfo.Margin({ 0, 0, 0, 0 }); holdEnterInfo.Margin({ 0, 0, 0, 0 });
stackPanel.Children().Append(holdEnterInfo); stackPanel.Children().Append(holdEnterInfo);