Page 1 of 1

Problem with TTreeNodeShape.ClickedImage

Posted: Tue Jul 26, 2005 8:40 am
by 9342815
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

Posted: Tue Jul 26, 2005 5:32 pm
by Tom
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:

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; 
or change the clickedImage method in teeTree.pas as follows:

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;
Regards,
tom at steema.com

Posted: Wed Jul 27, 2005 6:59 am
by 9342815
It works fine now

Thanks a lot Tom

Nico