Page 1 of 2

Mouse cursor vs CursorTool

Posted: Tue Oct 28, 2008 10:32 pm
by 13050481
I have an application where I have a TChart control over which I set the cursor depending on the area under the mouse cursor.
I simply use the MouseMove event to do that.
Works fine. exept when I activate my CursorTool.
It seems that when the CursorTool is activated, the TChart.Cursor is being overwritten by the CursorTool itself.

Setting the TChart.Cursor in the MouseMove works, but I noticed that the cursor was flickering badly. It is in fact alternating between my cursor and the Arrow.

Jean

Additionnal info

Posted: Wed Oct 29, 2008 12:10 pm
by 13050481
I think I have a better clue of what is happening:

The CursorTool actually saves the original TChart.Cursor in a private originalCursor variable.

When they are activated, the CursorTool use the originalCursor variable
to draw the cursor on the Chart and if this mouse cursor happens to be different than the one I set in the MouseMove event, the flickering occurs.

Does anybody know how to set the originalCursor variable ?

THanks,

Jean

Additionnal thoughts

Posted: Wed Oct 29, 2008 2:36 pm
by 13050481
A more accurate description would be this:

If a cursortool is active, it controls the Cursor in the WHOLE chart area, even Axis, labels etc.

So I need to be able to either

1) switch off cursor control by the cursortool
or
2) have a way to tell it what the "DefaultCursor" is

Posted: Thu Oct 30, 2008 11:22 am
by narcis
Hi johnyboy,

Have you tried setting CursorTool's FastCursor property to false? For example:

Code: Select all

			foreach (Steema.TeeChart.Tools.Tool t in tChart1.Tools)
			{
				if (t is Steema.TeeChart.Tools.CursorTool)
				{
					((Steema.TeeChart.Tools.CursorTool)t).FastCursor = false;
				}
			}

An example ?

Posted: Thu Oct 30, 2008 12:16 pm
by 13050481
Narcis,

Thanks for your suggestion, but I think an example would help clarify what I mean.

I am new to your website: where can I post my example ?

Jean

Posted: Thu Oct 30, 2008 12:52 pm
by narcis
Hi Jean,

You can post your files at news://www.steema.net/steema.public.attachments newsgroup or at our upload page.

Thanks in advance.

Sample code usage note

Posted: Thu Oct 30, 2008 1:04 pm
by 13050481
Narcis,

When you try the code I have uploaded, I suggest this:

Start the application
Check the "CursorTool Active" checkbox
Move your mouse over the chart area
Hit the "Change Cursor" Button
Move your mouse over the chart area
You should see the flickering I am talking about.

Thanks,

Jean

Posted: Thu Oct 30, 2008 2:53 pm
by narcis
Hi Jean,

Thanks for your file. It would be much easier and quicker if you sent the entire project so that we can run it "as-is".

Thanks in advance.

Zipped project

Posted: Thu Oct 30, 2008 2:57 pm
by 13050481
Narcis,

I have sent you the whole project.

Jean

Posted: Thu Oct 30, 2008 4:08 pm
by narcis
Hi Jean,

Thanks for the example project. I'm not able to reproduce the problem here using latest release availabe at the client area (build 3.5.3188.18560/1/2) and the instructions you posted. Which TeeChart version are you using?

Thanks in advance.

Posted: Thu Oct 30, 2008 4:19 pm
by 13050481
Narcis,

I am using version 3.5.3188.18561.

The problem was barely noticeable on my own machine. (WinXP SP2)

Its only at deployment time that installing the sw on a test machine revealed a much worse behavior.

If your machine is like my machine, you have to move the mouse slowly over the chart area and you will (i hope) see that once in a while and for just a brief moment, a different mouse cursor gets painted. You may want to try different mouse cursors (the "Change Cursor" button) as different originalCursor, actualCursor combination seemed to be more noticeable.

Additionnaly, If you break at the first line of the MouseMove, you can confirm that:
the current TChart.Cursor is always reset to the same CursorTool.originalCursor value, even if I set it otherwise.

Hope this will help,

Jean

Posted: Fri Oct 31, 2008 12:57 pm
by narcis
Hi Jean,

Thanks for the information but I'm still unable to reproduce the issue here.

I've built your application's exe with the very same TeeChart version you are using and I'll send it to you. Could you please copy it next to your TeeChart.dll and check if the problem occurs?

Thanks in advance.

It does indeed...

Posted: Fri Oct 31, 2008 4:10 pm
by 13050481
Yes Narcis,

The problem is still there.

I have made mpeg movies (!) of the problem on my machine and also on another machine where the problem is much worse.

Can I upload these files (each is approx 15 MB in size)

Jean

Posted: Fri Oct 31, 2008 4:16 pm
by narcis
Hi Jean,

Ok, you can try posting the files at the upload page and if they fail you could send them to us using www.yousendit.com and sending them to info at steema dot com to my attention.

Thanks in advance.

Posted: Tue Nov 04, 2008 11:42 am
by narcis
Hi Jean,

Thanks for the video. We think the problem is that a CursorTool needs to be created every time chart's cursor is being changed so that you can do something like this:

Code: Select all

        private System.Windows.Forms.Button button1;
        private Steema.TeeChart.TChart tChart1;
        private Steema.TeeChart.Styles.FastLine fastLine1;
        private Steema.TeeChart.Tools.CursorTool cursorTool1;
        private System.Windows.Forms.CheckBox checkBox1;

        private int CurrentCursor = 0;
        public Form1()
        {
            InitializeComponent();
            fastLine1.FillSampleValues(1000);
            cursorTool1.Active = false;
        }

        private void SetCursor()
				{
					tmpX = cursorTool1.XValue;
					tmpY = cursorTool1.YValue;

					switch (CurrentCursor)
					{
						case 0:
							tChart1.Cursor = Cursors.Arrow;
							break;
						case 1:
							tChart1.Cursor = Cursors.Cross;
							break;
						case 2:
							tChart1.Cursor = Cursors.Hand;
							break;
						case 3:
							tChart1.Cursor = Cursors.No;
							break;
					}

					tChart1.Tools.Remove(cursorTool1);
					tChart1.Tools.Add(cursorTool1 = new Steema.TeeChart.Tools.CursorTool());
					cursorTool1.Series = fastLine1;
					cursorTool1.Pen.Color = Color.Yellow;
					cursorTool1.YValue = tmpY;
					cursorTool1.XValue = tmpX;
					cursorTool1.YValue = tmpY;
					cursorTool1.Active = checkBox1.Checked;
        }

			private double tmpX, tmpY;

        private void button1_Click(object sender, EventArgs e)
        {
            CurrentCursor = ++CurrentCursor % 4;
            SetCursor();
        }

        private void tChart1_MouseMove(object sender, MouseEventArgs e)
        {
						//SetCursor();
        }

        private void checkBox1_CheckedChanged(object sender, EventArgs e)
        {
            cursorTool1.Active = checkBox1.Checked;
        }
Please notice that SetCursor() doesn't need to be called in the MouseMove event.

Could you please check if that works fine at your end?