TCursorTool trap events

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
PoLabs
Newbie
Newbie
Posts: 35
Joined: Fri Feb 05, 2010 12:00 am

TCursorTool trap events

Post by PoLabs » Wed May 26, 2010 12:11 pm

Hi,

Currently I am using TCursorTool.OnChange to detect change and do some operations. I have problems that OnChange event is called too fast or to many times. I would actually need one event which is fired when move of cursor is done. As I see OnChange is fired everytime the mouse moves which is problem for my application. I need to filter that somehow that OnChange would be fired only when change was made and mouse button is not down anymore. This mean that change would appear only when I stop to move cursor and unpress mouse button.

Now it is like:

1. Mouse button pressed to grab cursor
2. Mouse is moving (and cursor) so fire event OnChange

but I would need this way:

1. Mouse button pressed to grab cursor
2. Mouse is moving (and cursor)
3. Mouse button is up so stop moving cursor
4. If cursor new position differe from prevous position fire event OnChange


Does cursor tool offer any solutions to that (I cannot use snap while I have many points)? What do you suggest? Is possible somehow to trap that mouse events?

Thanks.
Br,
PoLabs

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

Re: TCursorTool trap events

Post by Yeray » Thu May 27, 2010 7:47 am

Hi Br,

Yes, you can use the mouse events OnMouseDown, OnMouseMove and OnMouseUp to do this, or you can use the CursorTool OnChange evend with OnMouseUp as follows:

Code: Select all

var CursorChanged: Boolean;

procedure TForm1.FormCreate(Sender: TObject);
begin
  CursorChanged:=false;
end;

procedure TForm1.ChartTool1Change(Sender: TCursorTool; x, y: Integer;
  const XValue, YValue: Double; Series: TChartSeries; ValueIndex: Integer);
begin
  CursorChanged:=true;
end;

procedure TForm1.Chart1MouseUp(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Integer);
begin
  if CursorChanged then
  begin
    CursorChanged:=false;

    ShowMessage('Do the CursorChanged job');
  end;
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

PoLabs
Newbie
Newbie
Posts: 35
Joined: Fri Feb 05, 2010 12:00 am

Re: TCursorTool trap events

Post by PoLabs » Thu May 27, 2010 1:05 pm

Yep, that was very good solution. Thanks. ;)

BR,
PoLabs

Post Reply