I am trying to see if my cursor is in a certain position inside of a TTreeNodeShape or on the Tree.
I see how to do it with a TChart (CacPosPoint in the help doc, "Custom drawing on the Chart"), is there an equivalent for TTree.
I can do it just fine, if the chart is not zoomed, but as soon as I zoom, I can't figure out the math to get me the correct chart coordinate with zoom level and scroll bar position.
TeeChart cursor pos to chart pos (CalcPosPoint equivalent)
-
- Newbie
- Posts: 5
- Joined: Fri Aug 29, 2008 12:00 am
Re: TeeChart cursor pos to chart pos (CalcPosPoint equivalent)
Hi,
I'd do it with the Clicked method. Have you tried it?
The following works fine for me here:
I'd do it with the Clicked method. Have you tried it?
The following works fine for me here:
Code: Select all
procedure TForm1.Tree1MouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
begin
if TreeNodeShape1.Clicked(X,Y) then Caption:='over the shape'
else Caption:='';
end;
Best Regards,
Yeray Alonso Development & Support Steema Software Av. Montilivi 33, 17003 Girona, Catalonia (SP) | |
Please read our Bug Fixing Policy |
-
- Newbie
- Posts: 5
- Joined: Fri Aug 29, 2008 12:00 am
Re: TeeChart cursor pos to chart pos (CalcPosPoint equivalent)
Yes, I do this, but I need to know if the mouse is in a certain spot in the shape.
Example : If mouse is over top half or shape then Caption := 'Top Section' else if in bottom half then Caption := 'Bottom Section'
node := tttGraphic.ClickedShape(x, y);
realY := tttGraphic.HorzScrollBar.Position;
if (realY > (node.Top + (node.Height div2))) and
(realY < node.Top) then
begin
tttGraphic.Hint := 'Top Section'
end
else if (realY < (node.Top + (node.Height div2))) and
(realY > (node.Top+node.Height)) then
begin
tttGraphic.Hint := 'Bottom Section'
end;
This works fine with a 100% zoom, but as soon as I change the zoom it will no longer work. I tried multiplying x,y by the zoom %, but that didn't work. I need to translate the mouse X,Y position to the Graphic position.
Thanks,
Steve
Example : If mouse is over top half or shape then Caption := 'Top Section' else if in bottom half then Caption := 'Bottom Section'
node := tttGraphic.ClickedShape(x, y);
realY := tttGraphic.HorzScrollBar.Position;
if (realY > (node.Top + (node.Height div2))) and
(realY < node.Top) then
begin
tttGraphic.Hint := 'Top Section'
end
else if (realY < (node.Top + (node.Height div2))) and
(realY > (node.Top+node.Height)) then
begin
tttGraphic.Hint := 'Bottom Section'
end;
This works fine with a 100% zoom, but as soon as I change the zoom it will no longer work. I tried multiplying x,y by the zoom %, but that didn't work. I need to translate the mouse X,Y position to the Graphic position.
Thanks,
Steve
-
- Newbie
- Posts: 5
- Joined: Fri Aug 29, 2008 12:00 am
Re: TeeChart cursor pos to chart pos (CalcPosPoint equivalent)
Never mind, I found it.
tttGraphic.Canvas.Calculate2DPosition(realX, realY, 0);
tttGraphic.Canvas.Calculate2DPosition(realX, realY, 0);
Re: TeeChart cursor pos to chart pos (CalcPosPoint equivalent)
Hi,
I'm glad to see you've found it!
I'm glad to see you've found it!
Best Regards,
Yeray Alonso Development & Support Steema Software Av. Montilivi 33, 17003 Girona, Catalonia (SP) | |
Please read our Bug Fixing Policy |