MouseUp sender is not the clicked component

A forum dedicated to WinForms version of LightningChart Ultimate.

Moderator: Queue Moderators

Post Reply
Igor
Posts: 67
Joined: Mon Sep 28, 2015 1:14 pm

MouseUp sender is not the clicked component

Post by Igor » Tue Sep 29, 2015 8:45 am

Hi,

I want to show differents context menus for each component type (e.g. Y-Axis, LegendBox...).
Therefore I need to know which component was clicked.

For this I looked at the example "ExampleAnnotationsXY.cs".
In the MouseUp event the sender corresponds the clicked item.

But in my sample project the sender is always the LightningChart.
Do I have to set a special property or something else, so that the sender is my clicked component?

Thank you very much

Igor

User avatar
ArctionPasi
Posts: 1367
Joined: Tue Mar 26, 2013 10:57 pm
Location: Finland
Contact:

Re: MouseUp sender is not the clicked component

Post by ArctionPasi » Wed Sep 30, 2015 9:38 am

Every mouse-interactive object of LightningChart, like LightningChart itself, series, annotation, titles, legend boxes, axes etc. have their own set of mouse events. Chart's events can't be used for handling these sub-objects. Chart's events fire if no other mouse-interactive object was clicked, practically just the chart background. It fires also if sub-object's MouseInteraction = false, meaning that mouse hit test is not made for the sub-object at all.

To respond for example to annotation's MouseDoubleClick event, subscribe to annotation's MouseDoubleClick:

Code: Select all

_chart.ViewXY.Annotations[0].MouseDoubleClick += new MouseEventHandler(annotation_MouseDoubleClick);

void annotation_MouseDoubleClick(object sender, MouseEventArgs e)
        {
            //sender is AnnotationXY 
        }


or X axis: 
_chart.ViewXY.XAxes[0].MouseOverOn += new MouseEventHandler(xAxis_MouseOverOn);

  void xAxis_MouseOverOn(object sender, MouseEventArgs e)
        {
            if (sender is Arction.LightningChartUltimate.Axes.AxisX)
            {

                MessageBox.Show(((Arction.LightningChartUltimate.Axes.AxisX)sender).Maximum.ToString("0.00"));
            }
        }
I hope this helps.
LightningChart Support Team, PT

Post Reply