Skip to content

Commit 6a8d46c

Browse files
Merge pull request #1302 from UweRaabe/Move_DoPopupMenu_to_WMContextMenu_#1301
Move DoPopupMenu from WMRButtonUp to WMContextMenu #1301
2 parents 3fbcf47 + 0bc3318 commit 6a8d46c

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

Source/VirtualTrees.BaseTree.pas

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6472,8 +6472,18 @@ procedure TBaseVirtualTree.WMContextMenu(var Message: TWMContextMenu);
64726472
// This method is called when a popup menu is about to be displayed.
64736473
// We have to cancel some pending states here to avoid interferences.
64746474

6475+
var
6476+
HitInfo: THitInfo;
6477+
pt: TPoint;
64756478
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;
64776487

64786488
if not (tsPopupMenuShown in FStates) then
64796489
inherited;
@@ -7735,7 +7745,7 @@ procedure TBaseVirtualTree.WMRButtonUp(var Message: TWMRButtonUp);
77357745
HitInfo: THitInfo;
77367746

77377747
begin
7738-
DoStateChange([], [tsPopupMenuShown, tsRightButtonDown]);
7748+
DoStateChange([], [tsRightButtonDown]);
77397749

77407750
if FHeader.States = [] then
77417751
begin
@@ -7756,8 +7766,6 @@ procedure TBaseVirtualTree.WMRButtonUp(var Message: TWMRButtonUp);
77567766
if toRightClickSelect in FOptions.SelectionOptions then
77577767
HandleMouseUp(Message, HitInfo);
77587768

7759-
if not Assigned(PopupMenu) then
7760-
DoPopupMenu(HitInfo.HitNode, HitInfo.HitColumn, Point(Message.XPos, Message.YPos));
77617769
end;
77627770
end;
77637771

0 commit comments

Comments
 (0)