Browse Source

Bug 1568: Make Ctrl-number custom keyboard shortcuts work on numeric keypad too

https://winscp.net/tracker/1568

Source commit: 563c47b4bdece22c0131585bd470a2295cb6c267
Martin Prikryl 8 years ago
parent
commit
844d6f20f9

+ 5 - 4
source/forms/CustomScpExplorer.cpp

@@ -4202,14 +4202,15 @@ void __fastcall TCustomScpExplorerForm::KeyDown(Word & Key, Classes::TShiftState
       TTerminalManager::Instance()->CycleTerminals(!Shift.Contains(ssShift));
     }
 
-    if (IsCustomShortCut(KeyShortCut))
+    TShortCut CustomShortCut = NormalizeCustomShortCut(KeyShortCut);
+    if (IsCustomShortCut(CustomShortCut))
     {
-      CheckCustomCommandShortCut(WinConfiguration->CustomCommandList, Key, Shift, KeyShortCut);
-      CheckCustomCommandShortCut(WinConfiguration->ExtensionList, Key, Shift, KeyShortCut);
+      CheckCustomCommandShortCut(WinConfiguration->CustomCommandList, Key, Shift, CustomShortCut);
+      CheckCustomCommandShortCut(WinConfiguration->ExtensionList, Key, Shift, CustomShortCut);
 
       if (WinConfiguration->SharedBookmarks != NULL)
       {
-        TBookmark * Bookmark = WinConfiguration->SharedBookmarks->FindByShortCut(KeyShortCut);
+        TBookmark * Bookmark = WinConfiguration->SharedBookmarks->FindByShortCut(CustomShortCut);
         if ((Bookmark != NULL) &&
             OpenBookmark(Bookmark->Local, Bookmark->Remote))
         {

+ 11 - 0
source/windows/UserInterface.cpp

@@ -1107,6 +1107,8 @@ int __fastcall StartThread(void * SecurityAttributes, unsigned StackSize,
 //---------------------------------------------------------------------------
 static TShortCut FirstCtrlNumberShortCut = ShortCut(L'0', TShiftState() << ssCtrl);
 static TShortCut LastCtrlNumberShortCut = ShortCut(L'9', TShiftState() << ssCtrl);
+static TShortCut FirstCtrlKeyPadShortCut = ShortCut(VK_NUMPAD0, TShiftState() << ssCtrl);
+static TShortCut LastCtrlKeyPadShortCut = ShortCut(VK_NUMPAD9, TShiftState() << ssCtrl);
 static TShortCut FirstShiftCtrlAltLetterShortCut = ShortCut(L'A', TShiftState() << ssShift << ssCtrl << ssAlt);
 static TShortCut LastShiftCtrlAltLetterShortCut = ShortCut(L'Z', TShiftState() << ssShift << ssCtrl << ssAlt);
 //---------------------------------------------------------------------------
@@ -1172,6 +1174,15 @@ TShortCut __fastcall GetShortCutCombo(TComboBox * ComboBox)
   return TShortCut(ComboBox->Items->Objects[ComboBox->ItemIndex]);
 }
 //---------------------------------------------------------------------------
+TShortCut __fastcall NormalizeCustomShortCut(TShortCut ShortCut)
+{
+  if ((FirstCtrlKeyPadShortCut <= ShortCut) && (ShortCut <= LastCtrlKeyPadShortCut))
+  {
+    ShortCut = FirstCtrlNumberShortCut + (ShortCut - FirstCtrlKeyPadShortCut);
+  }
+  return ShortCut;
+}
+//---------------------------------------------------------------------------
 bool __fastcall IsCustomShortCut(TShortCut ShortCut)
 {
   return

+ 1 - 0
source/windows/WinInterface.h

@@ -483,6 +483,7 @@ void __fastcall InitializeShortCutCombo(TComboBox * ComboBox,
 void __fastcall SetShortCutCombo(TComboBox * ComboBox, TShortCut Value);
 TShortCut __fastcall GetShortCutCombo(TComboBox * ComboBox);
 bool __fastcall IsCustomShortCut(TShortCut ShortCut);
+TShortCut __fastcall NormalizeCustomShortCut(TShortCut ShortCut);
 
 #ifdef _DEBUG
 void __fastcall ForceTracing();