Recent

Author Topic: TTReeView Dynamic popupmenu.  (Read 403 times)

sergioantonio2013

  • New Member
  • *
  • Posts: 22
TTReeView Dynamic popupmenu.
« on: September 24, 2019, 10:42:50 pm »
I want to have different menus popup depending on what item you right click on the TTReeView.
any idea, how this can be done, the easy way if there is one.


jamie

  • Hero Member
  • *****
  • Posts: 3538
Re: TTReeView Dynamic popupmenu.
« Reply #1 on: September 25, 2019, 12:26:57 am »
assuming you are having issues how to determine which node you are clicking on?
Code: Pascal  [Select][+][-]
  1. procedure TForm1.TreeView1MouseDown(Sender: TObject; Button: TMouseButton;
  2.   Shift: TShiftState; X, Y: Integer);
  3. Var
  4.   N:TTreeNode;
  5. begin
  6.  If Sender is TtreeView Then With TTreeView(Sender) do
  7.   Begin
  8.     N := GetNodeAt(X,Y);
  9.   if (N <> Nil)and (ssRight in Shift) then
  10.   Begin
  11.      Form1.Caption := N.Text;
  12.      { Call a PopUp Here using a Case to determine which one to call }
  13.      { Or Use the N.DATA pointer to point to a record containing info about it }
  14.      { The Record can hold the Instance for the Menu }
  15.   end;
  16.  end;
  17. end;                                
  18.  

 Hope that helps you get started.
The only true wisdom is knowing you know nothing

sergioantonio2013

  • New Member
  • *
  • Posts: 22
Re: TTReeView Dynamic popupmenu.
« Reply #2 on: September 25, 2019, 01:46:26 pm »
Thanks that worked.
« Last Edit: September 25, 2019, 02:07:32 pm by sergioantonio2013 »

 

TinyPortal © 2005-2018