Right-clicking (and keeping the right mouse button pressed) on a chart area allows me to drag the chart (surely a LightningChart functionality). When I add a WinForms ContextMenuStrip (plus several ToolStripMenuItems etc. as children) plus an event handler function, a right click opens that context menu, but now I am not able to use the drag function anymore.
Is there a way to use both, a custom context menu when I push the right mouse button, plus the drag function from LightningChart when I move the mouse while still having the right mouse button pressed?
Many thanks for help!
Niels
Custom context menu plus dragging a chart
Moderator: Queue Moderators
-
- Posts: 12
- Joined: Mon Nov 22, 2021 8:12 am
-
- Posts: 12
- Joined: Mon Nov 22, 2021 8:12 am
Re: Custom context menu plus dragging a chart
I thought about it again. The best would be a function like in windows file explorer: holding the right mouse button down on a file allows dragging the file, releasing the button opens the context menu. Transferred to LightningChart: holding the right mouse button down allows dragging, releasing the button opens my context menu.
Again: any help is highly appreciated!
Cheers
Niels
Again: any help is highly appreciated!
Cheers
Niels
-
- Posts: 557
- Joined: Mon Mar 14, 2016 9:22 am
Re: Custom context menu plus dragging a chart
Our Demo's ExampleAnnotationsXY has similar idea with Menu implementation. In that example menu is shown if MouseUp event occur above Annotation.
It is not difficult to keep mouse-right button dragging functionality on the chart and add "Menu showing functionality" on up event. Relevant WinForms code would be following:
Subscribe to chart.MouseUp event
And use something like this to show Menu:
By the way, with chart.ViewXY.ZoomPanOptions properties you can change which action (zoom, pan etc.) is associated with any mouse button.
Hope this helps.
It is not difficult to keep mouse-right button dragging functionality on the chart and add "Menu showing functionality" on up event. Relevant WinForms code would be following:
Subscribe to chart.MouseUp event
Code: Select all
chart.MouseUp += Chart_MouseUp;
Code: Select all
private void Chart_MouseUp(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Right)
{
//Show context menu for the annotation
contextMenuStrip1.Show(_chart, e.X, e.Y);
}
}
Hope this helps.