Skip to content

Commit

Permalink
Fix for issue #1243: Header DblClickResize and HeaderClickAutoSort: S…
Browse files Browse the repository at this point in the history
…tore if previous message was a double click,
  • Loading branch information
joachimmarder committed Mar 10, 2024
1 parent 7df624d commit 7971cd3
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion Source/VirtualTrees.Header.pas
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,7 @@ TVTHeader = class(TPersistent)
FDragImage : TVTDragImage; //drag image management during header drag
FLastWidth : TDimension; //Used to adjust spring columns. This is the width of all visible columns, not the header rectangle.
FRestoreSelectionColumnIndex : Integer; //The column that is used to implement the coRestoreSelection option
FWasDoubleClick : Boolean; // The previous mouse message was for a double click, that allows us to process mouse-up-messages differently
function GetMainColumn : TColumnIndex;
function GetUseColumns : Boolean;
function IsFontStored : Boolean;
Expand Down Expand Up @@ -1520,9 +1521,11 @@ function TVTHeader.HandleMessage(var Message : TMessage) : Boolean;
CheckBoxHit := False;
end;
end;
fWasDoubleClick := False;
end;
WM_LBUTTONDBLCLK, WM_NCLBUTTONDBLCLK, WM_NCMBUTTONDBLCLK, WM_NCRBUTTONDBLCLK :
begin
fWasDoubleClick := True;
if Message.Msg <> WM_LBUTTONDBLCLK then
with TWMNCLButtonDblClk(Message) do
P := FOwner.ScreenToClient(Point(XCursor, YCursor))
Expand Down Expand Up @@ -1664,6 +1667,7 @@ function TVTHeader.HandleMessage(var Message : TMessage) : Boolean;
HandleMessage := TVirtualTreeColumnsCracker(FColumns).HandleClick(P, TMouseButton.mbRight, True, False);
TBaseVirtualTreeCracker(FOwner).DoHeaderMouseUp(TMouseButton.mbRight, GetShiftState, P.X, P.Y + FHeight);
end;
fWasDoubleClick := False;
end;
//When the tree window has an active mouse capture then we only get "client-area" messages.
WM_LBUTTONUP, WM_NCLBUTTONUP :
Expand Down Expand Up @@ -1729,6 +1733,7 @@ function TVTHeader.HandleMessage(var Message : TMessage) : Boolean;
end;
Result := True;
Message.Result := 0;
fWasDoubleClick := False;
end;

case Message.Msg of
Expand All @@ -1742,14 +1747,17 @@ function TVTHeader.HandleMessage(var Message : TMessage) : Boolean;
end;
if FStates <> [] then
TBaseVirtualTreeCracker(FOwner).DoHeaderMouseUp(TMouseButton.mbLeft, KeysToShiftState(Keys), XPos, YPos);
fWasDoubleClick := False;
end;
WM_NCLBUTTONUP :
begin
with TWMNCLButtonUp(Message) do
P := FOwner.ScreenToClient(Point(XCursor, YCursor));
TVirtualTreeColumnsCracker(FColumns).HandleClick(P, TMouseButton.mbLeft, True, False);
if not fWasDoubleClick then
TVirtualTreeColumnsCracker(FColumns).HandleClick(P, TMouseButton.mbLeft, True, False);
TBaseVirtualTreeCracker(FOwner).DoHeaderMouseUp(TMouseButton.mbLeft, GetShiftState, P.X, P.Y + FHeight);
Result := True;
fWasDoubleClick := False;
end;
end;

Expand Down

0 comments on commit 7971cd3

Please sign in to comment.