Page 1 of 1

Disable right mouse for cursor tool moving

Posted: Tue Jun 21, 2011 10:28 am
by 13051494
Dear Support Team,
I have a vertical cursor in chart, and I only want to move the cursor tool by pressed left mouse. I don't want to move the cursor by pressed right mouse.
Could you please help me to solve this issue?
Now we can move the cursor by both pressed left and right mouse.
Thank you!

Re: Disable right mouse for cursor tool moving

Posted: Tue Jun 21, 2011 12:22 pm
by 10050769
Hello tomking,

I have made a simple project using MouseDown and MouseMove events to disable drag of cursor when you click RightMouse.

Code: Select all

public Form1()
        {
            InitializeComponent();
            InitializeChart();
        }
        Steema.TeeChart.Styles.Line lineSeries1;
        Steema.TeeChart.Tools.CursorTool cursor;
        private void InitializeChart()
        {
            lineSeries1 = new Steema.TeeChart.Styles.Line(tChart1.Chart);

            lineSeries1.FillSampleValues();
            cursor = new Steema.TeeChart.Tools.CursorTool(tChart1.Chart);
            cursor.Style = Steema.TeeChart.Tools.CursorToolStyles.Vertical;
            tChart1.MouseDown += new MouseEventHandler(tChart1_MouseDown);
            tChart1.MouseMove += new MouseEventHandler(tChart1_MouseMove);
        }
        int X;
        void tChart1_MouseMove(object sender, MouseEventArgs e)
        {
            if (e.Button == MouseButtons.Right)
            {
                cursor.XValue = tChart1.Axes.Bottom.CalcPosPoint(X);
            }
        }
       void tChart1_MouseDown(object sender, MouseEventArgs e)
       {
           X = e.X;
       }
Could you tell us if previous code works as you want? Moreover also you can use ColorLine Tool and disable AllowDrag property when you click buttonRigh using Mouse events.

I hope will helps.

Thanks,

Re: Disable right mouse for cursor tool moving

Posted: Wed Jun 22, 2011 6:36 am
by 13051494
Dear Sandra,
Thank for your replying.

It work if we do right mouse down and keep pressed mouse. But it does not work as my request.
When I do mouse down click by right mouse button on the cursor tool and then do mouse up. The cursor tool follows the mouse until the we do left mouse click.
I don't want the cursor tool follow the mouse after I do mouse up event.
If you have any solution for this issue. Please help me!

Thanks

Re: Disable right mouse for cursor tool moving

Posted: Wed Jun 22, 2011 9:22 am
by 10050769
Hello tomking,

I have tested again my code and works fine for me. If you can take a look in my code you can see that I am using FollowMouse and FastCursor properties with their default values that in this case are false. So if you don't want that cursorTool follows cursor after do click with right button you need disable FollowMouse. You can disable it, in MouseClick event for example, as do in next lines of code:

Code: Select all

 void tChart1_MouseClick(object sender, MouseEventArgs e)
            {
                if (e.Button == MouseButtons.Right)
                {
                    cursor.FollowMouse = false;
                }
                else if (e.Button == MouseButtons.Left)
                {
                    cursor.FollowMouse = true;
                }
            }
            int X;
            void tChart1_MouseMove(object sender, MouseEventArgs e)
            {
                if (e.Button == MouseButtons.Right)
                {
                   
                    cursor.XValue = tChart1.Axes.Bottom.CalcPosPoint(X);
              
                }
               
            }
           void tChart1_MouseDown(object sender, MouseEventArgs e)
           {
               X = e.X;
           }
Could you confirm us if previous code works as you expected? On the other hand, can you tell us which version of TeeChart are you using now?

I hope will helps.

Thanks,

Re: Disable right mouse for cursor tool moving

Posted: Thu Jun 23, 2011 1:19 am
by 13051494
Hello Sandra,

Actually, It has worked well since applied your first code.
The problem is that I assigned a context menu into the Tchat control. So when I do right mouse click and do mouse up, the cursor will still follow the mouse.
So I rejected the context menu and display it in manual way.
I have fixed this issue.

Thank you very much!