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 rhyminkevin, Today, 04:58 PM
|
3 responses
47 views
0 likes
|
Last Post
by Anfedport
Today, 05:24 PM
|
||
Started by iceman2018, Today, 05:07 PM
|
0 responses
5 views
0 likes
|
Last Post
by iceman2018
Today, 05:07 PM
|
||
Started by lightsun47, Today, 03:51 PM
|
0 responses
7 views
0 likes
|
Last Post
by lightsun47
Today, 03:51 PM
|
||
Started by 00nevest, Today, 02:27 PM
|
1 response
14 views
0 likes
|
Last Post
by 00nevest
Today, 03:48 PM
|
||
Started by futtrader, 04-21-2024, 01:50 AM
|
4 responses
50 views
0 likes
|
Last Post
by futtrader
Today, 03:01 PM
|
Comment