TCursorTool.cursor?

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
ChainSmokinCoder
Newbie
Newbie
Posts: 12
Joined: Wed Jun 01, 2005 4:00 am
Location: wellington
Contact:

TCursorTool.cursor?

Post by ChainSmokinCoder » Tue Apr 19, 2011 1:46 am

Hi,

Is there a way to change the TControl.cursor property of TCursorTool? It's the drag icon when you put the mouse pointer over the CursorTool. I'd like to remove it completely so the user won't try to drag the CursorTool. Well you see, the way to move the CursorTool in my software is by FollowMouse. So if the user click the CursorTool, it will turn FollowMouse on and another click will turn it off. But most users when the move the mouse over the CursorTool, seing the drag icon, they immediately try to click and drag the CursorTool, which is NOT what I want.
Anyway, changing the TCursorTool.Cursor doesn't do anything.

Thanks in advance.

Bert B.
Newbie
Newbie
Posts: 69
Joined: Fri Jun 15, 2007 12:00 am

Re: TCursorTool.cursor?

Post by Bert B. » Tue Apr 19, 2011 9:11 am

Disabling the drag cursor is a good suggestion, it would be useful for me too.

In the mean time you can set the ClickTolerance to 0 (instead of the default 3) to reduce the chance to see the drag icon.

Yeray
Site Admin
Site Admin
Posts: 9602
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Re: TCursorTool.cursor?

Post by Yeray » Tue Apr 19, 2011 12:56 pm

Hello Bert,

I'm afraid it's not possible to disable the dragging appearance of the Cursor Tool. However it is possible to disable the AllowDrag property in the TColorLineTool so you could use mouse events to control two Color Lines. Her it is an example:

Code: Select all

uses Series, TeeTools;

type
 TColorLineClicked=(clcNone,clcHorizontal,clcVertical,clcBoth);

var ClickedMode: TColorLineClicked;
    MouseX, MouseY: Integer;

procedure TForm1.FormCreate(Sender: TObject);
begin
  Chart1.View3D:=false;

  Chart1.AddSeries(TPointSeries).FillSampleValues();

  with Chart1.Tools.Add(TColorLineTool) as TColorLineTool do
  begin
    Axis:=Chart1.Axes.Bottom;
    Value:=Chart1[0].XValues.MaxValue / 2;
    AllowDrag:=false;
  end;

  with Chart1.Tools.Add(TColorLineTool) as TColorLineTool do
  begin
    Axis:=Chart1.Axes.Left;
    Value:=Chart1[0].YValues.MinValue + Chart1[0].YValues.Range / 2;
    AllowDrag:=false;
  end;

  ClickedMode:=clcNone;
end;

procedure TForm1.Chart1Click(Sender: TObject);
begin
  if ClickedMode = clcNone then
  begin
    if (Chart1.Tools[0] as TColorLineTool).Clicked(MouseX, MouseY) then
      ClickedMode:=clcVertical;

    if (Chart1.Tools[1] as TColorLineTool).Clicked(MouseX, MouseY) then
    begin
      if ClickedMode=clcVertical then
        ClickedMode:=clcBoth
      else
        ClickedMode:=clcHorizontal;
    end;
  end
  else ClickedMode:=clcNone;
end;

procedure TForm1.Chart1MouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer);
begin
  MouseX:=X;
  MouseY:=Y;

  if ((ClickedMode=clcBoth) or (ClickedMode=clcVertical)) then
    (Chart1.Tools[0] as TColorLineTool).Value:=Chart1.Axes.Bottom.CalcPosPoint(X);
  if ((ClickedMode=clcBoth) or (ClickedMode=clcHorizontal)) then
    (Chart1.Tools[1] as TColorLineTool).Value:=Chart1.Axes.Left.CalcPosPoint(Y);
end;
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

ChainSmokinCoder
Newbie
Newbie
Posts: 12
Joined: Wed Jun 01, 2005 4:00 am
Location: wellington
Contact:

Re: TCursorTool.cursor?

Post by ChainSmokinCoder » Tue Apr 19, 2011 9:27 pm

Reducing the drag tolerance wont help since I still need the cursors to be easily clickable to activate the followMouse.
So, no way at all to alter this than tinker with the source then? All good. Thanks anyway.

Yeray
Site Admin
Site Admin
Posts: 9602
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Re: TCursorTool.cursor?

Post by Yeray » Wed Apr 20, 2011 1:19 pm

Hello,

If you want to add some tolerance to the TColorLineTool, you could do the "clicked" method manually as follows:

Code: Select all

uses Series, TeeTools;

type
 TColorLineClicked=(clcNone,clcHorizontal,clcVertical,clcBoth);

var ClickedMode: TColorLineClicked;
    MouseX, MouseY, ClickTolerance: Integer;

procedure TForm1.FormCreate(Sender: TObject);
begin
  Chart1.View3D:=false;

  Chart1.AddSeries(TPointSeries).FillSampleValues();

  with Chart1.Tools.Add(TColorLineTool) as TColorLineTool do
  begin
    Axis:=Chart1.Axes.Bottom;
    Value:=Chart1[0].XValues.MaxValue / 2;
    AllowDrag:=false;
  end;

  with Chart1.Tools.Add(TColorLineTool) as TColorLineTool do
  begin
    Axis:=Chart1.Axes.Left;
    Value:=Chart1[0].YValues.MinValue + Chart1[0].YValues.Range / 2;
    AllowDrag:=false;
  end;

  ClickedMode:=clcNone;
  ClickTolerance:=20;
end;

procedure TForm1.Chart1Click(Sender: TObject);
begin
  if ClickedMode = clcNone then
  begin
    with (Chart1.Tools[0] as TColorLineTool) do
      if (Abs(MouseX-Axis.CalcPosValue(Value))<ClickTolerance) then
      ClickedMode:=clcVertical;

    with (Chart1.Tools[1] as TColorLineTool) do
      if (Abs(MouseY-Axis.CalcPosValue(Value))<ClickTolerance) then
      begin
        if ClickedMode=clcVertical then
          ClickedMode:=clcBoth
        else
          ClickedMode:=clcHorizontal;
      end;
  end
  else ClickedMode:=clcNone;
end;

procedure TForm1.Chart1MouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer);
begin
  MouseX:=X;
  MouseY:=Y;

  if ((ClickedMode=clcBoth) or (ClickedMode=clcVertical)) then
    (Chart1.Tools[0] as TColorLineTool).Value:=Chart1.Axes.Bottom.CalcPosPoint(X);
  if ((ClickedMode=clcBoth) or (ClickedMode=clcHorizontal)) then
    (Chart1.Tools[1] as TColorLineTool).Value:=Chart1.Axes.Left.CalcPosPoint(Y);
end;
Doesn't it work as you want?
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

ChainSmokinCoder
Newbie
Newbie
Posts: 12
Joined: Wed Jun 01, 2005 4:00 am
Location: wellington
Contact:

Re: TCursorTool.cursor?

Post by ChainSmokinCoder » Thu Apr 21, 2011 4:18 am

I'm a bit confused. Is TColorLineTool works the same way as TCursorTool?

Yeray
Site Admin
Site Admin
Posts: 9602
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Re: TCursorTool.cursor?

Post by Yeray » Thu Apr 21, 2011 3:40 pm

Hello,

Not exactly. They are designed for different purposes. Please, take a look at the examples in the features demo program included with the installation to have an idea about it.
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

Post Reply