Page 1 of 1

Scope of TCursorTool grabbing mouse cursor

Posted: Fri Oct 09, 2009 7:58 pm
by 10054271
I have a TCursorTool on a chart. It's Style is both. The horizontal and vertical sizes are both set to 10. This makes the cursor appear as a cross-hair. When the mouse cursor is anywhere on the chart, whenever it crosses the projection of the cursor lines, the mouse pointer changes to indicate that the TCursorTool is below the mouse. You can also click and drag at that point, even though the visible TCursorTool is far from the mouse pointer. Is there a way to restrict this behavior to the 10 pixels that are actually visible.

That may be a little cryptic. As an example, if the TCursorTool is positioned at 0,0, then when the mouse pointer passes over 1000, 0, it changes, and I can click and drag the TCursorTool from there, even though the mouse is nowhere near the TCursorTool. This could be very confusing to a user.

Re: Scope of TCursorTool grabbing mouse cursor

Posted: Tue Oct 13, 2009 11:27 am
by narcis
Hi skassan,

The only solution I can think of for now is doing something like this:

Code: Select all

uses TeCanvas;

procedure TForm4.Chart1MouseMove(Sender: TObject; Shift: TShiftState; X,
  Y: Integer);
var R: TRect;
    tmpX, tmpY: Integer;
    tmp: Boolean;
begin
  tmpX:=Chart1.Axes.Bottom.CalcXPosValue(ChartTool1.XValue);
  tmpY:=Chart1.Axes.Left.CalcYPosValue(ChartTool1.YValue);

  R.Left:=tmpX - ChartTool1.HorizSize div 2;
  R.Top:=tmpY - ChartTool1.VertSize div 2;
  R.Right:=R.Left + ChartTool1.HorizSize;
  R.Bottom:=R.Top + ChartTool1.VertSize;

  tmp:=PointInRect(R, X, Y);
  Chart1.AutoRepaint:=tmp;
  ChartTool1.Active:=tmp;
end;
Anyway, I'll add your request to the wish-list to be considered for inclusion in future releases.