Disable right mouse for cursor tool moving

TeeChart for Microsoft Visual Studio .NET, Xamarin Studio (Android, iOS & Forms) & Monodevelop.
Post Reply
tomking
Newbie
Newbie
Posts: 20
Joined: Thu Jan 15, 2009 12:00 am
Contact:

Disable right mouse for cursor tool moving

Post by tomking » Tue Jun 21, 2011 10:28 am

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!

Sandra
Site Admin
Site Admin
Posts: 3132
Joined: Fri Nov 07, 2008 12:00 am

Re: Disable right mouse for cursor tool moving

Post by Sandra » Tue Jun 21, 2011 12:22 pm

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,
Best Regards,
Sandra Pazos / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

tomking
Newbie
Newbie
Posts: 20
Joined: Thu Jan 15, 2009 12:00 am
Contact:

Re: Disable right mouse for cursor tool moving

Post by tomking » Wed Jun 22, 2011 6:36 am

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

Sandra
Site Admin
Site Admin
Posts: 3132
Joined: Fri Nov 07, 2008 12:00 am

Re: Disable right mouse for cursor tool moving

Post by Sandra » Wed Jun 22, 2011 9:22 am

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,
Best Regards,
Sandra Pazos / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

tomking
Newbie
Newbie
Posts: 20
Joined: Thu Jan 15, 2009 12:00 am
Contact:

Re: Disable right mouse for cursor tool moving

Post by tomking » Thu Jun 23, 2011 1:19 am

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!

Post Reply