@@ -6472,8 +6472,18 @@ procedure TBaseVirtualTree.WMContextMenu(var Message: TWMContextMenu);
6472
6472
// This method is called when a popup menu is about to be displayed.
6473
6473
// We have to cancel some pending states here to avoid interferences.
6474
6474
6475
+ var
6476
+ HitInfo: THitInfo;
6477
+ pt: TPoint;
6475
6478
begin
6476
- DoStateChange([], [tsClearPending, tsEditPending, tsOLEDragPending, tsVCLDragPending]);
6479
+ DoStateChange([], [tsClearPending, tsEditPending, tsOLEDragPending, tsVCLDragPending, tsPopupMenuShown]);
6480
+
6481
+ if not Assigned(PopupMenu) then begin
6482
+ // convert screen coordinates to client
6483
+ pt := ScreenToClient(Point(Message.XPos, Message.YPos));
6484
+ GetHitTestInfoAt(Message.XPos, Message.YPos, True, HitInfo); // ShiftState is not used anyway here
6485
+ DoPopupMenu(HitInfo.HitNode, HitInfo.HitColumn, pt);
6486
+ end;
6477
6487
6478
6488
if not (tsPopupMenuShown in FStates) then
6479
6489
inherited;
@@ -7735,7 +7745,7 @@ procedure TBaseVirtualTree.WMRButtonUp(var Message: TWMRButtonUp);
7735
7745
HitInfo: THitInfo;
7736
7746
7737
7747
begin
7738
- DoStateChange([], [tsPopupMenuShown, tsRightButtonDown]);
7748
+ DoStateChange([], [tsRightButtonDown]);
7739
7749
7740
7750
if FHeader.States = [] then
7741
7751
begin
@@ -7756,8 +7766,6 @@ procedure TBaseVirtualTree.WMRButtonUp(var Message: TWMRButtonUp);
7756
7766
if toRightClickSelect in FOptions.SelectionOptions then
7757
7767
HandleMouseUp(Message, HitInfo);
7758
7768
7759
- if not Assigned(PopupMenu) then
7760
- DoPopupMenu(HitInfo.HitNode, HitInfo.HitColumn, Point(Message.XPos, Message.YPos));
7761
7769
end;
7762
7770
end;
7763
7771
0 commit comments