Announcement
Collapse
Looking for a User App or Add-On built by the NinjaTrader community?
Visit NinjaTrader EcoSystem and our free User App Share!
Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less
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.
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; ...
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.Chris L.NinjaTrader Customer Service
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by algospoke, Yesterday, 06:40 PM
|
2 responses
20 views
0 likes
|
Last Post
by algospoke
Today, 07:04 PM
|
||
Started by ghoul, Today, 06:02 PM
|
3 responses
14 views
0 likes
|
Last Post Today, 06:43 PM | ||
Started by jeronymite, 04-12-2024, 04:26 PM
|
3 responses
45 views
0 likes
|
Last Post
by jeronymite
Yesterday, 10:10 PM
|
||
Started by Barry Milan, Yesterday, 10:35 PM
|
7 responses
21 views
0 likes
|
Last Post Today, 06:16 PM | ||
Started by AttiM, 02-14-2024, 05:20 PM
|
10 responses
181 views
0 likes
|
Last Post
by jeronymite
Today, 06:11 PM
|
Comment