View Issue Details

IDProjectCategoryView StatusLast Update
0000691Double CommanderGraphical user interfacepublic2019-06-08 15:28
Reporterglandvador Assigned ToAlexx2000  
PrioritynormalSeverityfeatureReproducibilityhave not tried
Status closedResolutionfixed 
ProjectionnoneETAnone 
PlatformLinux 
Product Version0.6.0 (trunk) 
Target Version0.6.0Fixed in Version0.6.0 
Summary0000691: [Patch] Rename file (as pressing F2 key) with left mouse button
DescriptionWhen clicking on an already selected file with the left button, after a second timeout if the mouse pointer still on the same file then the cm_renameonly function is called.
TagsNo tags attached.
Attached Files
rename_on_long_press.patch (3,329 bytes)   
Index: src/fileviews/ufileviewwithmainctrl.pas
===================================================================
--- src/fileviews/ufileviewwithmainctrl.pas	(revision 5250)
+++ src/fileviews/ufileviewwithmainctrl.pas	(working copy)
@@ -55,6 +55,7 @@
 
     procedure SetMainControl(AValue: TWinControl);
     procedure tmContextMenuTimer(Sender: TObject);
+    procedure tmRenameFileTimer(Sender: TObject);
     // If internal dragging is currently in effect, this function
     // stops internal dragging and starts external.
     procedure TransformDraggingToExternal(ScreenPoint: TPoint);
@@ -83,6 +84,8 @@
     FDropFileIndex: PtrInt;
     FStartDrag: Boolean;
     tmContextMenu: TTimer;
+    FRenameFileIndex: PtrInt;
+    tmRenameFile: TTimer;
     // Simulates releasing mouse button that started a dragging operation,
     // but was released in another window or another application.
     procedure ClearAfterDragDrop; virtual;
@@ -211,6 +214,12 @@
   tmContextMenu.Enabled  := False;
   tmContextMenu.Interval := 500;
   tmContextMenu.OnTimer  := @tmContextMenuTimer;
+
+  tmRenameFile := TTimer.Create(Self);
+  tmRenameFile.Enabled  := False;
+  tmRenameFile.Interval := 1000;
+  tmRenameFile.OnTimer  := @tmRenameFileTimer;
+  FRenameFileIndex := -1;
 end;
 
 destructor TFileViewWithMainCtrl.Destroy;
@@ -573,6 +582,7 @@
   begin
     AFile := FFiles[FileIndex];
     FMainControlLastMouseButton := Button;
+    FRenameFileIndex := -1;
 
     case Button of
       mbRight:
@@ -613,6 +623,14 @@
             end
           else if (gMouseSelectionButton = 0) then
             begin
+              // start the rename file timer if the actual file is clicked again
+              APreviousFile := GetActiveDisplayFile;
+              if Assigned(APreviousFile) and (APreviousFile = AFile) then
+              begin
+                FRenameFileIndex := FileIndex;
+                tmRenameFile.Enabled := True;
+              end;
+
               if not AFile.Selected then
                 MarkFiles(False);
             end;
@@ -714,6 +732,13 @@
       end;
     end;
 
+  // disable the rename file timer if we are dragging
+  if MainControl.Dragging then
+  begin
+     tmRenameFile.Enabled := False;
+     FRenameFileIndex := -1;
+  end;
+
   // Show file info tooltip.
   if ShowHint and
      not MainControl.Dragging and ([ssLeft, ssMiddle, ssRight] * Shift = []) then
@@ -1043,6 +1068,31 @@
   frmMain.Commands.DoContextMenu(Self, MousePoint.x, MousePoint.y, Background);
 end;
 
+procedure TFileViewWithMainCtrl.tmRenameFileTimer(Sender: TObject);
+var
+  ClientPoint, MousePoint: TPoint;
+  Background: Boolean;
+  FileIndex: PtrInt;
+  AtFileList: Boolean;
+begin
+  FMainControlMouseDown := False;
+  tmRenameFile.Enabled := False; // stop timer
+
+  MousePoint  := Mouse.CursorPos;
+  ClientPoint := MainControl.ScreenToClient(MousePoint);
+  FileIndex   := GetFileIndexFromCursor(ClientPoint.x, ClientPoint.y, AtFileList);
+  Background  := not IsFileIndexInRange(FileIndex);
+
+  if not Background then
+  begin
+    if FRenameFileIndex = FileIndex then
+    begin
+      cm_RenameOnly([]);
+    end;
+  end;
+  FRenameFileIndex := -1;
+end;
+
 procedure TFileViewWithMainCtrl.TransformDraggingToExternal(ScreenPoint: TPoint);
 begin
   // Set flag temporarily before stopping internal dragging,
rename_on_long_press.patch (3,329 bytes)   
rename_on_left_press_v2.patch (3,667 bytes)   
Index: src/fileviews/ufileviewwithmainctrl.pas
===================================================================
--- src/fileviews/ufileviewwithmainctrl.pas	(revision 5250)
+++ src/fileviews/ufileviewwithmainctrl.pas	(working copy)
@@ -55,6 +55,7 @@
 
     procedure SetMainControl(AValue: TWinControl);
     procedure tmContextMenuTimer(Sender: TObject);
+    procedure tmRenameFileTimer(Sender: TObject);
     // If internal dragging is currently in effect, this function
     // stops internal dragging and starts external.
     procedure TransformDraggingToExternal(ScreenPoint: TPoint);
@@ -83,6 +84,8 @@
     FDropFileIndex: PtrInt;
     FStartDrag: Boolean;
     tmContextMenu: TTimer;
+    FRenameFileIndex: PtrInt;
+    tmRenameFile: TTimer;
     // Simulates releasing mouse button that started a dragging operation,
     // but was released in another window or another application.
     procedure ClearAfterDragDrop; virtual;
@@ -211,6 +214,12 @@
   tmContextMenu.Enabled  := False;
   tmContextMenu.Interval := 500;
   tmContextMenu.OnTimer  := @tmContextMenuTimer;
+
+  tmRenameFile := TTimer.Create(Self);
+  tmRenameFile.Enabled  := False;
+  tmRenameFile.Interval := 1000;
+  tmRenameFile.OnTimer  := @tmRenameFileTimer;
+  FRenameFileIndex := -1;
 end;
 
 destructor TFileViewWithMainCtrl.Destroy;
@@ -573,6 +582,7 @@
   begin
     AFile := FFiles[FileIndex];
     FMainControlLastMouseButton := Button;
+    FRenameFileIndex := -1;
 
     case Button of
       mbRight:
@@ -613,6 +623,14 @@
             end
           else if (gMouseSelectionButton = 0) then
             begin
+              // start the rename file timer if the actual file is clicked again
+              APreviousFile := GetActiveDisplayFile;
+              if Assigned(APreviousFile) and (APreviousFile = AFile) then
+              begin
+                FRenameFileIndex := FileIndex;
+                tmRenameFile.Enabled := True;
+              end;
+
               if not AFile.Selected then
                 MarkFiles(False);
             end;
@@ -714,6 +732,13 @@
       end;
     end;
 
+  // disable the rename file timer if we are dragging
+  if MainControl.Dragging then
+  begin
+     tmRenameFile.Enabled := False;
+     FRenameFileIndex := -1;
+  end;
+
   // Show file info tooltip.
   if ShowHint and
      not MainControl.Dragging and ([ssLeft, ssMiddle, ssRight] * Shift = []) then
@@ -1033,6 +1058,10 @@
   FileIndex   := GetFileIndexFromCursor(ClientPoint.x, ClientPoint.y, AtFileList);
   Background  := not IsFileIndexInRange(FileIndex);
 
+  // skip if a rename is in progress on the same file
+  if FRenameFileIndex = FileIndex then
+    Exit;
+
   if not Background then
   begin
     AFile := FFiles[FileIndex];
@@ -1043,6 +1072,31 @@
   frmMain.Commands.DoContextMenu(Self, MousePoint.x, MousePoint.y, Background);
 end;
 
+procedure TFileViewWithMainCtrl.tmRenameFileTimer(Sender: TObject);
+var
+  ClientPoint, MousePoint: TPoint;
+  Background: Boolean;
+  FileIndex: PtrInt;
+  AtFileList: Boolean;
+begin
+  FMainControlMouseDown := False;
+  tmRenameFile.Enabled := False; // stop timer
+
+  MousePoint  := Mouse.CursorPos;
+  ClientPoint := MainControl.ScreenToClient(MousePoint);
+  FileIndex   := GetFileIndexFromCursor(ClientPoint.x, ClientPoint.y, AtFileList);
+  Background  := not IsFileIndexInRange(FileIndex);
+
+  if not Background then
+  begin
+    if FRenameFileIndex = FileIndex then
+    begin
+      cm_RenameOnly([]);
+    end;
+  end;
+  FRenameFileIndex := -1;
+end;
+
 procedure TFileViewWithMainCtrl.TransformDraggingToExternal(ScreenPoint: TPoint);
 begin
   // Set flag temporarily before stopping internal dragging,
rename_on_left_press_v2.patch (3,667 bytes)   
Fixed in Revision5656
Operating systemLinux
WidgetsetGTK2
Architecture32-bit

Relationships

has duplicate 0000140 closed Rename with double click 

Activities

glandvador

2013-07-10 17:09

reporter   ~0001070

[rename_on_left_press_v2]
 + Inhibit tmContextMenu timer if a rename is in progress.

Alexx2000

2014-10-26 13:55

administrator   ~0001323

Added, enabled in options at "File Views" page

Issue History

Date Modified Username Field Change
2013-07-09 20:12 glandvador New Issue
2013-07-09 20:12 glandvador File Added: rename_on_long_press.patch
2013-07-10 17:09 glandvador Note Added: 0001070
2013-07-10 17:09 glandvador File Added: rename_on_left_press_v2.patch
2013-08-24 01:41 cobines Relationship added has duplicate 0000140
2014-10-26 13:45 Alexx2000 Assigned To => Alexx2000
2014-10-26 13:45 Alexx2000 Status new => assigned
2014-10-26 13:45 Alexx2000 Target Version => 0.6.0
2014-10-26 13:55 Alexx2000 Fixed in Revision => 5656
2014-10-26 13:55 Alexx2000 Note Added: 0001323
2014-10-26 13:55 Alexx2000 Status assigned => resolved
2014-10-26 13:55 Alexx2000 Fixed in Version => 0.6.0
2014-10-26 13:55 Alexx2000 Resolution open => fixed
2019-06-08 15:28 Alexx2000 Status resolved => closed