annoying issue with implementing toggable state images for a TreeView lazarus / 31-LCL ---------------------------------------------------------------------- jamie · 2020-04-18 21:51 Ether I missed something in this control or it just isn't there but I find my self implementing the long way a process of be able to toggle the state image for the TreeNodes.. So if there is an event I am missing please tell me, if there isn't then why don't we have this ? here is basically what I do, well in this particular project anyways Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i procedure Tprjtorpsf.TreeView1Click(Sender: TObject);var  PT:TPoint;  R:TRect;  N:TTreeNode;begin With TTreeView(Sender) do  Begin   PT := Mouse.CursorPos;   PT := ScreenToClient(PT);   if (Selected <> Nil)And(Selected.Parent = Nil) Then      begin       R := TRect.Create(Selected.DisplayStateIconLeft, Selected.Top,Selected.DisplayTextleft,Selected.Bottom);       if R.Contains(PT) Then       Begin        Selected.StateIndex := Selected.StateIndex xor 1;        if Selected.StateIndex <> 0 Then       Begin           {We much uncheck others..Only One }           N := Items.GetFirstNode;           While (N <> Nil) do            Begin           If N <> Selected Then N.stateIndex := 0;             N := N.GetNextSibling;            end;         end;       end;      end;  end;end;  A nice Event Like OnStateImage Click with the Node so I can alter it of course. Am I missing something here ? ---------------------------------------------------------------------- wp · 2020-04-18 22:12 There's a function GetHitInfoAt(x,y) returning a set of htAbove, htBelow, htNowhere, htOnItem, htOnButton, htOnIcon, htOnIndent, htOnLabel, htOnRight, htOnStateIcon, htToLeft, htToRight, among them htOnStateIcon. Is it that what you are missing? ---------------------------------------------------------------------- jamie · 2020-04-18 22:17 I'll look at it, it could aid in a bit but I use the Click event now and covert the mouse x,y over to client x,y.. I suppose I still need to do this but that would save me a step...  Thanks I'll look at it.. ---------------------------------------------------------------------- wp · 2020-04-18 22:28 This works for me: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i procedure TForm1.TreeView1MouseDown(Sender: TObject; Button: TMouseButton;  Shift: TShiftState; X, Y: Integer);var  node: TTreeNode;begin  if (htOnStateIcon in Treeview1.GetHitTestInfoAt(X, Y)) then  begin    node := TreeView1.GetNodeAt(X, Y);    if node <> nil then      node.StateIndex := node.StateIndex xor 1;  end;end; ---------------------------------------------------------------------- jamie · 2020-04-18 22:42 LOL Are you looking over my shoulders because that is virtually identical to what I ended up with in that section of code..  Btw, I think the help file needs up dating.. There is no "GetNodeAt(X,Y)" but "GetNodeATY(Y)" Instead... Thanks for the help, I love using methods and code that are already in the soup bowl, don't like reinventing the wheel here ---------------------------------------------------------------------- wp · 2020-04-18 22:58 Quote from: jamie on April 19, 2020, 12:42:24 am Btw, I think the help file needs up dating.. There is no "GetNodeAt(X,Y)" but "GetNodeATY(Y)" Instead... There is a GetNodeAtY(Y) in the protected section and a GetNodeAt(X,Y) in the public section of TCustomTreeView. The chm of 2.0.6 lists them correctly ---------------------------------------------------------------------- jamie · 2020-04-18 23:14 You are absolutely correct, I got lost in the help file there... Sorry about that …  Its a good thing someone around here is still awake!