Преглед на файлове

While editing pretend that we do not have a popup menu otherwise Ctrl+V is swallowed due to the "paste" files action with the same shortcut

Reported by Ricardo.

Source commit: 621e033a12c796ecfb508b5f464382d122ab9ee0
Martin Prikryl преди 9 години
родител
ревизия
d0ce042714
променени са 1 файла, в които са добавени 18 реда и са изтрити 1 реда
  1. 18 1
      source/packages/my/NortonLikeListView.pas

+ 18 - 1
source/packages/my/NortonLikeListView.pas

@@ -4,7 +4,7 @@ interface
 
 uses
   Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
-  ComCtrls, ListViewColProperties, CommCtrl;
+  ComCtrls, ListViewColProperties, CommCtrl, Menus;
 
 type
   TCustomNortonLikeListView = class;
@@ -79,6 +79,7 @@ type
     function GetSelCount: Integer; override;
     procedure DDBeforeDrag;
     function CanEdit(Item: TListItem): Boolean; override;
+    function GetPopupMenu: TPopupMenu; override;
   public
     { Public declarations }
     constructor Create(AOwner: TComponent); override;
@@ -320,6 +321,22 @@ begin
     else Result := Item;
 end;
 
+function TCustomNortonLikeListView.GetPopupMenu: TPopupMenu;
+begin
+  // While editing pretend that we do not have a popup menu.
+  // Otherwise Ctrl+V is swallowed by the TWinControl.CNKeyDown,
+  // when it finds out (TWinControl.IsMenuKey) that there's a command with Ctrl+V shortcut in the list view context menu
+  // (the "paste" file action)
+  if IsEditing then
+  begin
+    Result := nil;
+  end
+    else
+  begin
+    Result := inherited;
+  end;
+end;
+
 procedure TCustomNortonLikeListView.WMNotify(var Message: TWMNotify);
 var
   HDNotify: PHDNotify;