Skip to content

Commit

Permalink
Close query tab on click with middle-mouse-button. Closes #779
Browse files Browse the repository at this point in the history
  • Loading branch information
ansgarbecker committed Dec 15, 2019
1 parent d5968e1 commit eb25bc5
Showing 1 changed file with 21 additions and 11 deletions.
32 changes: 21 additions & 11 deletions source/main.pas
Original file line number Diff line number Diff line change
Expand Up @@ -11183,18 +11183,28 @@ procedure TMainForm.PageControlMainMouseUp(Sender: TObject;
CurTickcount: Cardinal;
TabNumber: Integer;
begin
// Simulate doubleclick on tab to close it
if Button <> mbLeft then
Exit;
CurTickcount := GetTickCount;
TabNumber := GetMainTabAt(X, Y);
if (TabNumber = FLastTabNumberOnMouseUp)
and (CurTickcount - FLastMouseUpOnPageControl <= GetDoubleClickTime) then
CloseQueryTab(TabNumber)
else begin
FLastMouseUpOnPageControl := CurTickcount;
FLastTabNumberOnMouseUp := TabNumber;
// Handle click event on poor PageControl tabs in lack of an OnClick
case Button of
mbLeft: begin
// Simulate doubleclick on tab to close it
CurTickcount := GetTickCount;
TabNumber := GetMainTabAt(X, Y);
if (TabNumber = FLastTabNumberOnMouseUp)
and (CurTickcount - FLastMouseUpOnPageControl <= GetDoubleClickTime) then begin
CloseQueryTab(TabNumber);
end else begin
FLastMouseUpOnPageControl := CurTickcount;
FLastTabNumberOnMouseUp := TabNumber;
end;
end;

mbMiddle: begin
// Middle click on tab
TabNumber := GetMainTabAt(X, Y);
CloseQueryTab(TabNumber);
end;
end;

end;


Expand Down

0 comments on commit eb25bc5

Please sign in to comment.