Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
Capture chart mouse events from Add-On
Collapse
X
-
Capture chart mouse events from Add-On
I am wondering how an Add-On could capture mouse events (down, move, up) for a specific chart? For example, similar to a drawing tool, once add-on activated, capture the mouse events, and then once an action is completed stop capturing and let them flow back to the chart.Tags: None
-
Hello aslane,
Thanks for the post.
The ChartControl object has the MouseDownPoint property which will give you the (x,y) coordinates of the left mouse button whenever it is clicked or held.
There are mouse events built into C#, so you can use them in your chart panel, ChartControl, or TabControl.
There is an example of how to use MouseDownPoint on this help guide page:
Here is how to use Windows WPF controls, I am building this off of the AddOnFramework example.
Whenever you create your NTWindow or TabPage, subscribe your mouse event function in the constructor like so:
... denotes that I have left out code.
Then implement your event function underneath the constructor, still within the class:Code:public class AddOnFrameworkWindow : NTWindow, IWorkspacePersistence { public AddOnFrameworkWindow() { Caption = "AddOn Framework"; // Set the default dimensions of the window Width = 1085; Height = 900; TabControl tc = new TabControl(); tc.MouseLeftButtonDown += OnMouseDown; ...
Please see the following links for more information:Code:public class AddOnFrameworkWindow : NTWindow, IWorkspacePersistence { public AddOnFrameworkWindow() { ... tc.MouseLeftButtonDown += OnMouseDown; ... } public void OnMouseDown(object sender, MouseEventArgs e) { if (e.LeftButton == MouseButtonState.Pressed) { MessageBox.Show("The Left Mouse Button is pressed"); } } ...
https://ninjatrader.com/support/help...page_class.htm - NTTabPage Class
https://ninjatrader.com/support/help.../?ntwindow.htm - NTWindow
https://ninjatrader.com/support/help...chartpanel.htm - ChartPanel
https://ninjatrader.com/support/help...artcontrol.htm - Chart Control
https://ninjatrader.com/support/help...edownpoint.htm - MouseDownPoint
Here are some publicly available links on C# mouse event handling:
https://msdn.microsoft.com/en-us/lib...v=vs.110).aspx - MouseEventArgs
https://docs.microsoft.com/en-us/dot...input-overview - WPF Input overview.
Here is a link to the AddonFramework Visual Studio solution example, click on the link titled "Download Visual Studio Solution for AddOn Development":
Please let us know if we may be of further assistance.
Latest Posts
Collapse
| Topics | Statistics | Last Post | ||
|---|---|---|---|---|
|
Started by Geovanny Suaza, 02-11-2026, 06:32 PM
|
0 responses
577 views
0 likes
|
Last Post
|
||
|
Started by Geovanny Suaza, 02-11-2026, 05:51 PM
|
0 responses
334 views
1 like
|
Last Post
|
||
|
Started by Mindset, 02-09-2026, 11:44 AM
|
0 responses
101 views
0 likes
|
Last Post
by Mindset
02-09-2026, 11:44 AM
|
||
|
Started by Geovanny Suaza, 02-02-2026, 12:30 PM
|
0 responses
553 views
1 like
|
Last Post
|
||
|
Started by RFrosty, 01-28-2026, 06:49 PM
|
0 responses
551 views
1 like
|
Last Post
by RFrosty
01-28-2026, 06:49 PM
|

Comment