Skip to content

Commit

Permalink
Code review, restore default-old state when new row added in KBM
Browse files Browse the repository at this point in the history
  • Loading branch information
jefflord committed Feb 27, 2024
1 parent b59a3f3 commit 0aca2c5
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,7 @@ inline void CreateEditShortcutsWindowImpl(HINSTANCE hInst, KBMEditor::KeyboardMa
// Set focus to the first Type Button in the newly added row
UIHelpers::SetFocusOnTypeButtonInLastRow(shortcutTable, EditorConstants::ShortcutTableColCount);

newShortcut.OpenNewShortcutControlRow(shortcutTable, shortcutTable.Children().GetAt(shortcutTable.Children().Size() - 1).as<StackPanel>());
//newShortcut.OpenNewShortcutControlRow(shortcutTable, shortcutTable.Children().GetAt(shortcutTable.Children().Size() - 1).as<StackPanel>());
});

// if this is a delete action we just want to quick load the screen to delete the shortcut and close
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -459,36 +459,33 @@ void KeyDropDownControl::AddShortcutToControl(Shortcut shortcut, StackPanel tabl

auto secondKey = shortcut.GetSecondKey();

if (shortcutKeyCodes.size() != 0 || shortcut.IsRunProgram())
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)
{
bool ignoreWarning = false;
ignoreWarning = true;
}

// 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, row, parent, colIndex, remapBuffer, keyDropDownControlObjects, targetApp, isHybridControl, isSingleKeyWindow, ignoreWarning);

KeyDropDownControl::AddDropDown(table, row, parent, colIndex, remapBuffer, keyDropDownControlObjects, targetApp, isHybridControl, isSingleKeyWindow, ignoreWarning);

for (int i = 0; i < shortcutKeyCodes.size(); i++)
for (int i = 0; i < shortcutKeyCodes.size(); i++)
{
// New drop down gets added automatically when the SelectedValue(key code) is set
if (i < (int)parent.Children().Size())
{
// New drop down gets added automatically when the SelectedValue(key code) is set
if (i < (int)parent.Children().Size())
{
ComboBox currentDropDown = parent.Children().GetAt(i).as<ComboBox>();
currentDropDown.SelectedValue(winrt::box_value(std::to_wstring(shortcutKeyCodes[i])));
}
ComboBox currentDropDown = parent.Children().GetAt(i).as<ComboBox>();
currentDropDown.SelectedValue(winrt::box_value(std::to_wstring(shortcutKeyCodes[i])));
}
}

if (shortcut.HasChord())
{
// if this has a chord, render it last
KeyDropDownControl::AddDropDown(table, row, parent, colIndex, remapBuffer, keyDropDownControlObjects, targetApp, isHybridControl, isSingleKeyWindow, ignoreWarning);
auto nextI = static_cast<int>(shortcutKeyCodes.size());
ComboBox currentDropDown = parent.Children().GetAt(nextI).as<ComboBox>();
currentDropDown.SelectedValue(winrt::box_value(std::to_wstring(shortcut.GetSecondKey())));
}
if (shortcut.HasChord())
{
// if this has a chord, render it last
KeyDropDownControl::AddDropDown(table, row, parent, colIndex, remapBuffer, keyDropDownControlObjects, targetApp, isHybridControl, isSingleKeyWindow, ignoreWarning);
auto nextI = static_cast<int>(shortcutKeyCodes.size());
ComboBox currentDropDown = parent.Children().GetAt(nextI).as<ComboBox>();
currentDropDown.SelectedValue(winrt::box_value(std::to_wstring(shortcut.GetSecondKey())));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -527,6 +527,9 @@ ShortcutControl& ShortcutControl::AddNewShortcutControlRow(StackPanel& parent, s
{
// Initialize both shortcuts as empty shortcuts
shortcutRemapBuffer.push_back(std::make_pair<RemapBufferItem, std::wstring>(RemapBufferItem{ Shortcut(), Shortcut() }, std::wstring(targetAppName)));

KeyDropDownControl::AddShortcutToControl(originalKeys, parent, keyboardRemapControlObjects[keyboardRemapControlObjects.size() - 1][0]->shortcutDropDownVariableSizedWrapGrid.as<VariableSizedWrapGrid>(), *keyboardManagerState, 0, keyboardRemapControlObjects[keyboardRemapControlObjects.size() - 1][0]->keyDropDownControlObjects, shortcutRemapBuffer, row, targetAppTextBox, false, false);

}

return newShortcutToRemap;
Expand Down

0 comments on commit 0aca2c5

Please sign in to comment.