mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-05 18:57:19 +02:00
Add drop down key selection support to Keyboard Manager UI (dev/build-features) (#2140)
* Added combobox * Formatted and removed unused code * Added drop down support for Edit Keyboard window * Reordered the displayed key list * Add shortcut stack panels and drop downs linked to detect shortcut * Add more selected item logic * Added complete dropdown support for edit shortcuts window * Added Flyout warning for incorrect drop down input * Tweaked warnings * Removed MainWindow code * Changed SelectedValue toSelectedIndex * Removed unnecessary assignments * Added a warning for two dropdowns and the first one is changed to an action key * Added function comments in cpp file * Fixed some comments * Fixed all allocation and out of scope issues * Fix most issues except reloading shortcuts * Fixed issue while reloading shortcuts * Fixed type cast warnings * Changed delete to delete[] * tweaked
This commit is contained in:
@@ -391,26 +391,7 @@ void Shortcut::ResetKey(const DWORD& input, const bool& isWinBoth)
|
||||
}
|
||||
}
|
||||
|
||||
// Function to return the string representation of the shortcut
|
||||
winrt::hstring Shortcut::ToHstring(LayoutMap& keyboardMap)
|
||||
{
|
||||
std::vector<winrt::hstring> keys = GetKeyVector(keyboardMap);
|
||||
|
||||
winrt::hstring output;
|
||||
for (auto& key : keys)
|
||||
{
|
||||
output = output + key + winrt::to_hstring(L" ");
|
||||
}
|
||||
if (keys.size() > 1)
|
||||
{
|
||||
return winrt::hstring(output.c_str(), output.size() - 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
return output;
|
||||
}
|
||||
}
|
||||
|
||||
// Function to return a vector of hstring for each key in the display order
|
||||
std::vector<winrt::hstring> Shortcut::GetKeyVector(LayoutMap& keyboardMap) const
|
||||
{
|
||||
std::vector<winrt::hstring> keys;
|
||||
@@ -437,6 +418,43 @@ std::vector<winrt::hstring> Shortcut::GetKeyVector(LayoutMap& keyboardMap) const
|
||||
return keys;
|
||||
}
|
||||
|
||||
// Function to return a vector of key codes in the display order
|
||||
std::vector<DWORD> Shortcut::GetKeyCodes()
|
||||
{
|
||||
std::vector<DWORD> keys;
|
||||
if (winKey != ModifierKey::Disabled)
|
||||
{
|
||||
keys.push_back(GetWinKey(ModifierKey::Left));
|
||||
}
|
||||
if (ctrlKey != ModifierKey::Disabled)
|
||||
{
|
||||
keys.push_back(GetCtrlKey());
|
||||
}
|
||||
if (altKey != ModifierKey::Disabled)
|
||||
{
|
||||
keys.push_back(GetAltKey());
|
||||
}
|
||||
if (shiftKey != ModifierKey::Disabled)
|
||||
{
|
||||
keys.push_back(GetShiftKey());
|
||||
}
|
||||
if (actionKey != NULL)
|
||||
{
|
||||
keys.push_back(actionKey);
|
||||
}
|
||||
return keys;
|
||||
}
|
||||
|
||||
// Function to set a shortcut from a vector of key codes
|
||||
void Shortcut::SetKeyCodes(const std::vector<DWORD>& keys)
|
||||
{
|
||||
Reset();
|
||||
for (int i = 0; i < keys.size(); i++)
|
||||
{
|
||||
SetKey(keys[i]);
|
||||
}
|
||||
}
|
||||
|
||||
// Function to check if all the modifiers in the shortcut have been pressed down
|
||||
bool Shortcut::CheckModifiersKeyboardState() const
|
||||
{
|
||||
@@ -540,7 +558,7 @@ bool Shortcut::CheckModifiersKeyboardState() const
|
||||
bool Shortcut::IsKeyboardStateClearExceptShortcut() const
|
||||
{
|
||||
// Iterate through all the virtual key codes - 0xFF is set to key down because of the Num Lock
|
||||
for (int keyVal = 0; keyVal < 0xFF; keyVal++)
|
||||
for (int keyVal = 1; keyVal < 0xFF; keyVal++)
|
||||
{
|
||||
// Skip mouse buttons. Keeping this could cause a remapping to fail if a mouse button is also pressed at the same time
|
||||
if (keyVal == VK_LBUTTON || keyVal == VK_RBUTTON || keyVal == VK_MBUTTON || keyVal == VK_XBUTTON1 || keyVal == VK_XBUTTON2)
|
||||
|
||||
Reference in New Issue
Block a user