diff --git a/src/modules/keyboardmanager/ui/KeyDropDownControl.cpp b/src/modules/keyboardmanager/ui/KeyDropDownControl.cpp index 9bd6568783..6b42ae929a 100644 --- a/src/modules/keyboardmanager/ui/KeyDropDownControl.cpp +++ b/src/modules/keyboardmanager/ui/KeyDropDownControl.cpp @@ -148,6 +148,13 @@ std::pair KeyDropDownControl::ValidateSho parent.UpdateLayout(); } + // If ignore key to shortcut warning flag is true and it is a hybrid control in SingleKeyRemapControl, then skip MapToSameKey error + if (isHybridControl && isSingleKeyWindow && ignoreKeyToShortcutWarning && (validationResult.first == KeyboardManagerHelper::ErrorType::MapToSameKey)) + { + validationResult.first = KeyboardManagerHelper::ErrorType::NoError; + } + + // If the remapping is invalid display an error message if (validationResult.first != KeyboardManagerHelper::ErrorType::NoError) { SetDropDownError(currentDropDown, KeyboardManagerHelper::GetErrorMessage(validationResult.first)); @@ -170,6 +177,12 @@ std::pair KeyDropDownControl::ValidateSho } } + // Reset ignoreKeyToShortcutWarning + if (ignoreKeyToShortcutWarning) + { + ignoreKeyToShortcutWarning = false; + } + return std::make_pair(validationResult.first, rowIndex); } @@ -268,9 +281,9 @@ ComboBox KeyDropDownControl::GetComboBox() } // Function to add a drop down to the shortcut stack panel -void KeyDropDownControl::AddDropDown(Grid table, StackPanel shortcutControl, StackPanel parent, const int colIndex, RemapBuffer& shortcutRemapBuffer, std::vector>& keyDropDownControlObjects, TextBox targetApp, bool isHybridControl, bool isSingleKeyWindow) +void KeyDropDownControl::AddDropDown(Grid table, StackPanel shortcutControl, StackPanel parent, const int colIndex, RemapBuffer& shortcutRemapBuffer, std::vector>& keyDropDownControlObjects, TextBox targetApp, bool isHybridControl, bool isSingleKeyWindow, bool ignoreWarning) { - keyDropDownControlObjects.push_back(std::move(std::unique_ptr(new KeyDropDownControl(true)))); + keyDropDownControlObjects.push_back(std::move(std::unique_ptr(new KeyDropDownControl(true, ignoreWarning)))); parent.Children().Append(keyDropDownControlObjects[keyDropDownControlObjects.size() - 1]->GetComboBox()); keyDropDownControlObjects[keyDropDownControlObjects.size() - 1]->SetSelectionHandler(table, shortcutControl, parent, colIndex, shortcutRemapBuffer, keyDropDownControlObjects, targetApp, isHybridControl, isSingleKeyWindow); parent.UpdateLayout(); @@ -342,7 +355,16 @@ void KeyDropDownControl::AddShortcutToControl(Shortcut shortcut, Grid table, Sta std::vector keyCodeList = keyboardManagerState.keyboardMap.GetKeyCodeList(true); if (shortcutKeyCodes.size() != 0) { - KeyDropDownControl::AddDropDown(table, controlLayout, parent, colIndex, remapBuffer, keyDropDownControlObjects, targetApp, isHybridControl, isSingleKeyWindow); + bool ignoreWarning = false; + + // If more than one key is to be added, ignore a shortcut to key warning on partially entering the remapping + if (shortcutKeyCodes.size() > 1) + { + ignoreWarning = true; + } + + KeyDropDownControl::AddDropDown(table, controlLayout, parent, colIndex, remapBuffer, keyDropDownControlObjects, targetApp, isHybridControl, isSingleKeyWindow, ignoreWarning); + for (int i = 0; i < shortcutKeyCodes.size(); i++) { // New drop down gets added automatically when the SelectedIndex is set diff --git a/src/modules/keyboardmanager/ui/KeyDropDownControl.h b/src/modules/keyboardmanager/ui/KeyDropDownControl.h index 3d3c13961b..f50d37cfb4 100644 --- a/src/modules/keyboardmanager/ui/KeyDropDownControl.h +++ b/src/modules/keyboardmanager/ui/KeyDropDownControl.h @@ -38,6 +38,8 @@ private: winrt::Windows::Foundation::IInspectable warningMessage; // Stores the flyout attached to the current drop down winrt::Windows::Foundation::IInspectable warningFlyout; + // Stores whether a key to shortcut warning has to be ignored + bool ignoreKeyToShortcutWarning; // Function to set properties apart from the SelectionChanged event handler void SetDefaultProperties(bool isShortcut); @@ -53,7 +55,8 @@ public: static KeyboardManagerState* keyboardManagerState; // Constructor - the last default parameter should be passed as false only if it originates from Type shortcut or when an old shortcut is reloaded - KeyDropDownControl(bool isShortcut) + KeyDropDownControl(bool isShortcut, bool fromAddShortcutToControl = false) : + ignoreKeyToShortcutWarning(fromAddShortcutToControl) { SetDefaultProperties(isShortcut); } @@ -74,7 +77,7 @@ public: ComboBox GetComboBox(); // Function to add a drop down to the shortcut stack panel - static void AddDropDown(winrt::Windows::UI::Xaml::Controls::Grid table, winrt::Windows::UI::Xaml::Controls::StackPanel shortcutControl, winrt::Windows::UI::Xaml::Controls::StackPanel parent, const int colIndex, RemapBuffer& shortcutRemapBuffer, std::vector>& keyDropDownControlObjects, winrt::Windows::UI::Xaml::Controls::TextBox targetApp, bool isHybridControl, bool isSingleKeyWindow); + static void AddDropDown(winrt::Windows::UI::Xaml::Controls::Grid table, winrt::Windows::UI::Xaml::Controls::StackPanel shortcutControl, winrt::Windows::UI::Xaml::Controls::StackPanel parent, const int colIndex, RemapBuffer& shortcutRemapBuffer, std::vector>& keyDropDownControlObjects, winrt::Windows::UI::Xaml::Controls::TextBox targetApp, bool isHybridControl, bool isSingleKeyWindow, bool ignoreWarning = false); // Function to get the list of key codes from the shortcut combo box stack panel static std::vector GetSelectedIndicesFromStackPanel(StackPanel parent);