RobYost Posted February 11, 2017 Share Posted February 11, 2017 How do you know which node has been selected on a right click? This is the code I was using in VCL procedure TfrmMain.treeBuildingMouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);var aNode: TUniTreeNode; P: TPoint;begin if (Button = mbRight) then begin aNode := treeBuilding.GetNodeAt(X, Y); if (aNode <> nil) then begin treeBuilding.Selected := aNode; P.X := X; P.Y := Y; P := treeBuilding.ClientToScreen(P); popNewEntity.Popup(P.X, P.Y); end; end;end; Quote Link to comment Share on other sites More sharing options...
Sherzod Posted February 11, 2017 Share Posted February 11, 2017 Hi, Select also works when you press the right click. If you want to use the context menu, you can use this event of UniTreeView -> OnCellContextClick. For example: procedure TMainForm.UniTreeView1CellContextClick(ANode: TUniTreeNode; X, Y: Integer); begin UniPopupMenu1.Popup(X, Y); end; Best regards. Quote Link to comment Share on other sites More sharing options...
artem_niko Posted February 7, 2022 Share Posted February 7, 2022 On 2/11/2017 at 11:35 AM, Sherzod said: Hi, Select also works when you press the right click. If you want to use the context menu, you can use this event of UniTreeView -> OnCellContextClick. For example: procedure TMainForm.UniTreeView1CellContextClick(ANode: TUniTreeNode; X, Y: Integer); begin UniPopupMenu1.Popup(X, Y); end; Best regards. Good day! I have a question. How to write code to show UniPopupMenu right next to the mouse cursor, on the selected item in UniTreeView? Now my context menu appears somewhere away from where I right-clicked: Quote Link to comment Share on other sites More sharing options...
Sherzod Posted February 7, 2022 Share Posted February 7, 2022 1 hour ago, Артем said: How to write code to show UniPopupMenu right next to the mouse cursor, on the selected item in UniTreeView? Hello, procedure TMainForm.UniTreeView1CellContextClick(ANode: TUniTreeNode; X, Y: Integer); begin UniPopupMenu1.Popup(X, Y, ANode); end; 1 Quote Link to comment Share on other sites More sharing options...
artem_niko Posted February 7, 2022 Share Posted February 7, 2022 2 hours ago, Sherzod said: Hello, procedure TMainForm.UniTreeView1CellContextClick(ANode: TUniTreeNode; X, Y: Integer); begin UniPopupMenu1.Popup(X, Y, ANode); end; Thanks! Almost works as it should. Only, the context menu appears, as it were, ABOVE the mouse cursor, but it is necessary that it be BELOW it. How to fix it? Well, how it is done in the usual Word'e, where we right-click on the sheet. Quote Link to comment Share on other sites More sharing options...
Sherzod Posted February 7, 2022 Share Posted February 7, 2022 44 minutes ago, Артем said: Only, the context menu appears, as it were, ABOVE the mouse cursor, but it is necessary that it be BELOW it. Well, if I understand you correctly, you can increase the values: UniPopupMenu1.Popup(X+xx, Y+yy, ANode); 1 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.