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(cancelButton);
header.Children().Append(applyButton);
header.Children().Append(cancelButton);
// Add remap key button
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(cancelButton);
header.Children().Append(applyButton);
header.Children().Append(cancelButton);
// Add shortcut button
Windows::UI::Xaml::Controls::Button addShortcut;

View File

@@ -157,7 +157,7 @@ void ShortcutControl::createDetectShortcutWindow(winrt::Windows::Foundation::IIn
keyboardManagerState.ResetDetectedShortcutKey(key);
};
auto onAccept = [this,
auto onPressEnter = [this,
linkedShortcutStackPanel,
detectShortcutBox,
&keyboardManagerState,
@@ -173,13 +173,23 @@ void ShortcutControl::createDetectShortcutWindow(winrt::Windows::Foundation::IIn
// The shortcut buffer gets set in this function
AddShortcutToControl(detectedShortcutKeys, table, linkedShortcutStackPanel, keyboardManagerState, colIndex);
}
// Hide the type shortcut UI
detectShortcutBox.Hide();
};
auto onReleaseEnter = [&keyboardManagerState,
unregisterKeys] {
// Reset the keyboard manager UI state
keyboardManagerState.ResetUIState();
// Revert UI state back to Edit Shortcut window
keyboardManagerState.SetUIState(KeyboardManagerUIState::EditShortcutsWindowActivated, EditShortcutsWindowHandle);
unregisterKeys();
detectShortcutBox.Hide();
};
auto onAccept = [onPressEnter,
onReleaseEnter] {
onPressEnter();
onReleaseEnter();
};
TextBlock primaryButtonText;
@@ -198,20 +208,17 @@ void ShortcutControl::createDetectShortcutWindow(winrt::Windows::Foundation::IIn
keyboardManagerState.RegisterKeyDelay(
VK_RETURN,
selectDetectedShortcutAndResetKeys,
[primaryButton, detectShortcutBox](DWORD) {
[primaryButton, onPressEnter, detectShortcutBox](DWORD) {
detectShortcutBox.Dispatcher().RunAsync(
Windows::UI::Core::CoreDispatcherPriority::Normal,
[primaryButton] {
[primaryButton, onPressEnter] {
// 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>());
onPressEnter();
});
},
[onAccept, detectShortcutBox](DWORD) {
detectShortcutBox.Dispatcher().RunAsync(
Windows::UI::Core::CoreDispatcherPriority::Normal,
[onAccept] {
onAccept();
});
[onReleaseEnter](DWORD) {
onReleaseEnter();
});
TextBlock cancelButtonText;
@@ -270,7 +277,7 @@ void ShortcutControl::createDetectShortcutWindow(winrt::Windows::Foundation::IIn
stackPanel.Children().Append(holdEscInfo);
TextBlock holdEnterInfo;
holdEnterInfo.Text(L"Hold Enter to apply");
holdEnterInfo.Text(L"Hold Enter to continue");
holdEnterInfo.FontSize(12);
holdEnterInfo.Margin({ 0, 0, 0, 0 });
stackPanel.Children().Append(holdEnterInfo);

View File

@@ -131,7 +131,7 @@ void SingleKeyRemapControl::createDetectKeyWindow(winrt::Windows::Foundation::II
t2.detach();
};
auto onAccept = [linkedRemapDropDown,
auto onPressEnter = [linkedRemapDropDown,
detectRemapKeyBox,
&keyboardManagerState,
&singleKeyRemapBuffer,
@@ -150,13 +150,23 @@ void SingleKeyRemapControl::createDetectKeyWindow(winrt::Windows::Foundation::II
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
keyboardManagerState.ResetUIState();
// Revert UI state back to Edit Keyboard window
keyboardManagerState.SetUIState(KeyboardManagerUIState::EditKeyboardWindowActivated, EditKeyboardWindowHandle);
unregisterKeys();
detectRemapKeyBox.Hide();
};
auto onAccept = [onPressEnter,
onReleaseEnter] {
onPressEnter();
onReleaseEnter();
};
TextBlock primaryButtonText;
@@ -173,20 +183,17 @@ void SingleKeyRemapControl::createDetectKeyWindow(winrt::Windows::Foundation::II
keyboardManagerState.RegisterKeyDelay(
VK_RETURN,
std::bind(&KeyboardManagerState::SelectDetectedRemapKey, &keyboardManagerState, std::placeholders::_1),
[primaryButton, detectRemapKeyBox](DWORD) {
[primaryButton, onPressEnter, detectRemapKeyBox](DWORD) {
detectRemapKeyBox.Dispatcher().RunAsync(
Windows::UI::Core::CoreDispatcherPriority::Normal,
[primaryButton] {
[primaryButton, onPressEnter] {
// 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>());
onPressEnter();
});
},
[onAccept, detectRemapKeyBox](DWORD) {
detectRemapKeyBox.Dispatcher().RunAsync(
Windows::UI::Core::CoreDispatcherPriority::Normal,
[onAccept] {
onAccept();
});
[onReleaseEnter](DWORD) {
onReleaseEnter();
});
TextBlock cancelButtonText;
@@ -245,7 +252,7 @@ void SingleKeyRemapControl::createDetectKeyWindow(winrt::Windows::Foundation::II
stackPanel.Children().Append(holdEscInfo);
TextBlock holdEnterInfo;
holdEnterInfo.Text(L"Hold Enter to apply");
holdEnterInfo.Text(L"Hold Enter to continue");
holdEnterInfo.FontSize(12);
holdEnterInfo.Margin({ 0, 0, 0, 0 });
stackPanel.Children().Append(holdEnterInfo);