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_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,
|
---|