Page 1 of 1

TCursorTool

Posted: Sat Jan 29, 2005 1:00 am
by 9336236
I'm displaying a TCursorTool crosshair cursor on my chart. How do I get rid of the 'regular' cursor that is displayed as well? It looks strange to have them both displayed at the same time?

Posted: Mon Jan 31, 2005 6:57 am
by Marjan
Hi, Leroy.

Try setting TChart.OriginalCursor property to crNone:

Code: Select all

Chart1.OriginalCursor := crNone;

Posted: Sat Feb 05, 2005 12:32 am
by 9336236
Marjan wrote:Try setting TChart.OriginalCursor property to crNone:

Code: Select all

Chart1.OriginalCursor := crNone;
Thanks, Marjan. Works great.

While I'm on the subject... When I added the TCursorTool to the chart (via the Chart Editor), it assigned the name ChartTool1.

I don't like to use this in my code because it's not descriptive. I'd prefer to call it ChartCursorTool or something more descriptive. How can I specify the TCursorTool's name?

And one more quick question - How can I get the crosshair cursor to snap to the X axis but not the Y axis?

Posted: Sat Feb 05, 2005 8:46 pm
by 9336236
And a problem I just ran into. I added a keystroke to toggle between the Cross and CrossHair cursors.

This work OK, except that when I switch from the Cross to the CrossHair:

1) The Cross cursor remains on the screen until the cursor is moved
2) The CrossHair cursor comes up at a location different from that of the Cross cursor.

When I switch from the CrossHair cursor to the Cross cursor, the CrossHair cursor disappears from the screen, but the Cross cursor does not appear until the cursor is moved.

How can I fix these issues?

Posted: Tue Feb 08, 2005 4:17 pm
by Marjan
How can I specify the TCursorTool's name?
The easiest approach would be to use the "Object Inspector" and change the ChartTool1 Name to something else (can be done at design time).
And one more quick question - How can I get the crosshair cursor to snap to the X axis but not the Y axis?
Hmm.. Perhaps by using two cursors, vertical and horizontal ? Set the vertical cursor Snap and FollowMouse properties to True and Horizontal cursor FollowMouse property to True:

Code: Select all

With CursorTool1 do
begin
  FollowMouse := True;
  Series := Series1;
  Snap := True;
  Style := cssVertical;
end
With CursorTools2 do
begin
  FollowMouse := True;
  Series := Series1;
  Style := cssHorizontal;
end

Posted: Tue Feb 08, 2005 4:43 pm
by 9336236
Marjan wrote:
How can I specify the TCursorTool's name?
The easiest approach would be to use the "Object Inspector" and change the ChartTool1 Name to something else (can be done at design time).
I feel a bit silly asking this, but how do I get it displayed in the Object Inspector? I tried opening the Chart Editor (by double-clicking on the chart on my form), then clicking on the Tools Tab, then on my Cursor in the left-hand panel, but it does not appear in the Object Inspector.

I'm clearly missing something here.
Marjan wrote:
And one more quick question - How can I get the crosshair cursor to snap to the X axis but not the Y axis?
Hmm.. Perhaps by using two cursors, vertical and horizontal ? Set the vertical cursor Snap and FollowMouse properties to True and Horizontal cursor FollowMouse property to True:

Code: Select all

With CursorTool1 do
begin
  FollowMouse := True;
  Series := Series1;
  Snap := True;
  Style := cssVertical;
end
With CursorTools2 do
begin
  FollowMouse := True;
  Series := Series1;
  Style := cssHorizontal;
end
OK, I'll give this a try.

Posted: Wed Feb 09, 2005 7:33 am
by Marjan
Hi, Leroy.

Here are the necessary steps:

1) Create a application with single form,
2) Drop a TChart on the form
3) Right-click on the chart, select "Tools" tab
4) Click "Add" button, then select "Cursor" tool, then again "Add" button.
5) Select "Close" button to close chart editor
6) Go to "Object Inspector". You'll notice several items, including "ChartTool1". Select it and switch to "Properties" tab -> now you can change it's Name property.

Of course, this is all done at design time <g>.

Posted: Wed Feb 09, 2005 6:13 pm
by 9336236
Thanks, Marjan.

I originally thought that you meant that I should see the tool within the properties of the Chart itself, in a pop-up editor like I see for Custom Axes.

I finally realized that when you said to go to the object inspector, you were referring to the drop-down list above the object inspector. I did indeed find the tool in that list.