Forráskód Böngészése

Custom commands keyboard shortcuts work on Synchronization checklist dialog

Source commit: fd53f5801b8516cf207465672be3080df5479b10
Martin Prikryl 6 éve
szülő
commit
94c286bb52

+ 1 - 4
source/forms/NonVisual.cpp

@@ -1073,10 +1073,7 @@ int __fastcall TNonVisualDataModule::CreateCustomCommandsListMenu(
         Item->Tag = Item->Tag | CustomCommandBoth;
       }
       Item->Hint = CustomCommandHint(Command);
-      if (ListType != ccltBoth)
-      {
-        Item->ShortCut = Command->ShortCut;
-      }
+      Item->ShortCut = Command->ShortCut;
       Item->OnClick = CustomCommandClick;
 
       Menu->Add(Item);

+ 25 - 0
source/forms/SynchronizeChecklist.cpp

@@ -1387,3 +1387,28 @@ void __fastcall TSynchronizeChecklistDialog::BrowseRemoteActionExecute(TObject *
   DoBrowse(osRemote);
 }
 //---------------------------------------------------------------------------
+void __fastcall TSynchronizeChecklistDialog::KeyDown(Word & Key, TShiftState Shift)
+{
+  TShortCut KeyShortCut = ShortCut(Key, Shift);
+  TShortCut CustomShortCut = NormalizeCustomShortCut(KeyShortCut);
+  if (IsCustomShortCut(CustomShortCut))
+  {
+    TTBXItem * MenuItem = new TTBXItem(this);
+    CustomCommandsAction->ActionComponent = MenuItem;
+    CustomCommandsAction->Execute();
+
+    for (int Index = 0; Index < MenuItem->Count; Index++)
+    {
+      TTBCustomItem * Item = MenuItem->Items[Index];
+      if (Item->Enabled && (Item->ShortCut == CustomShortCut))
+      {
+        TAutoFlag DontCopyCommandToClipboardFlag(DontCopyCommandToClipboard);
+        Item->Click();
+        Key = 0;
+        break;
+      }
+    }
+  }
+
+  TForm::KeyDown(Key, Shift);
+}

+ 1 - 0
source/forms/SynchronizeChecklist.h

@@ -181,6 +181,7 @@ protected:
   void __fastcall DoBrowse(TOperationSide Side);
   void __fastcall ListViewHintShow(TCMHintShow & HintShow);
   void __fastcall StatusBarHintShow(TCMHintShow & HintShow);
+  DYNAMIC void __fastcall KeyDown(Word & Key, TShiftState Shift);
 };
 //----------------------------------------------------------------------------
 #endif