Hi
I have node with a picture (ImageIndex = tiChecked) and I'd like to know when the user click on this picture. So I wrote :
OnNodeClick(Sender: TTreeNodeShape;
Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
if Sender.ClickedImage(X, Y) then
begin
...
end;
...
end;
It works fine as long as I don't have any scrollbars with position <> 0 in the TeeTree component.
When I have a scrollbar with position <> 0, the XY coordinates are relative to component space and not the tree space.
Could you tell me what I have done wrong ?
Thanks
Nico
Problem with TTreeNodeShape.ClickedImage
Hi Nico,
You've nothing done wrong. I think it is a bug in the code.
You could solve it in two ways:
Change the code you present below to:
or change the clickedImage method in teeTree.pas as follows:
Regards,
tom at steema.com
You've nothing done wrong. I think it is a bug in the code.
You could solve it in two ways:
Change the code you present below to:
Code: Select all
OnNodeClick(Sender: TTreeNodeShape; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
Sender.Tree.Canvas.Calculate2DPosition(X,Y,0);
if Sender.ClickedImage(X, Y) then
begin
...
end;
...
end;
Code: Select all
Function TTreeNodeShape.ClickedImage(x,y:Integer):Boolean;
begin
Tree.Canvas.Calculate2DPosition(X,Y,0);
result:=(IImageWidth>0) and PointInRect(ImageRect,x,y);
end;
tom at steema.com