Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
[Request] - ChartTrader access
Collapse
X
-
Did this get lost or forgot about? I'm specifically asking why the left click doesn't work (middle and right do) when creating a button.MouseDown event..Originally posted by -=Edge=- View PostI've changed the Button.Click event to a Button.MouseDown event.. Seems the middle and right button events work.. But NOT the MouseButton.Left. The same thing occurs no matter how or where you use the button.. Could you please check this please.
Code:[COLOR=#0000ff]private[/COLOR] [COLOR=#0000ff]void[/COLOR] [COLOR=#080808]SampleButton_MDClick[/COLOR]([COLOR=#0000ff]object[/COLOR] [COLOR=#080808]sender[/COLOR], [COLOR=#080808]MouseButtonEventArgs[/COLOR] [COLOR=#080808]e[/COLOR]) { [COLOR=#008000] /////////////[/COLOR][COLOR=#008000] Left Button Click Is NOT Working!!!! [/COLOR][COLOR=#008000]/////////////////////// [/COLOR][COLOR=#0000ff] if[/COLOR]([COLOR=#080808]e[/COLOR].[COLOR=#080808]ChangedButton[/COLOR] == [COLOR=#080808]MouseButton[/COLOR].[COLOR=#080808]Left[/COLOR] && [COLOR=#080808]e[/COLOR].[COLOR=#080808]ButtonState [/COLOR]== [COLOR=#080808]MouseButtonState[/COLOR].[COLOR=#080808]Pressed[/COLOR]) { [COLOR=#080808] Print[/COLOR]([COLOR=#b22222]"CT Left Button is working"[/COLOR]); } [COLOR=#0000ff] if[/COLOR]([COLOR=#080808]e[/COLOR].[COLOR=#080808]ChangedButton[/COLOR] == [COLOR=#080808]MouseButton[/COLOR].[COLOR=#080808]Right[/COLOR] && [COLOR=#080808]e[/COLOR].[COLOR=#080808]ButtonState[/COLOR] == [COLOR=#080808]MouseButtonState[/COLOR].[COLOR=#080808]Pressed[/COLOR]) { [COLOR=#080808] Print[/COLOR]([COLOR=#b22222]"CT Right Button is working"[/COLOR]); } [COLOR=#0000ff] if[/COLOR]([COLOR=#080808]e[/COLOR].[COLOR=#080808]ChangedButton[/COLOR] == [COLOR=#080808]MouseButton[/COLOR].[COLOR=#080808]Middle[/COLOR] && [COLOR=#080808]e[/COLOR].[COLOR=#080808]ButtonState[/COLOR] == [COLOR=#080808]MouseButtonState[/COLOR].[COLOR=#080808]Pressed[/COLOR]) { [COLOR=#080808] Print[/COLOR]([COLOR=#b22222]"CT Middle Button is working"[/COLOR]); } }
Comment
-
Based on what I'm seeing, it seems that the left mouse down event is suppressed within Button.MouseDown. I was able to modify your code by adding a second event handler, PreviewMouseLeftButtonDown, which captured only the left click:
Code:sampleButton.PreviewMouseLeftButtonDown += SampleButton_LeftClick; sampleButton.MouseDown += SampleButton_MDClick; private void SampleButton_LeftClick(object sender, MouseButtonEventArgs e) { Print("CT Left Button is working"); } private void SampleButton_MDClick(object sender, MouseButtonEventArgs e) { if(e.ChangedButton == MouseButton.Right && e.ButtonState == MouseButtonState.Pressed) { Print("CT Right Button is working"); } if(e.ChangedButton == MouseButton.Middle && e.ButtonState == MouseButtonState.Pressed) { Print("CT Middle Button is working"); } }Dave I.NinjaTrader Product Management
Comment
-
Adding a second handler for several dozen buttons would not be very efficient.. But since I now know that the left mouse down is being suppressed and not a bug, just changing the MouseDown to PreviewMouseDown seems to work fine as one handler for all 3 buttons.Originally posted by NinjaTrader_Dave View PostBased on what I'm seeing, it seems that the left mouse down event is suppressed within Button.MouseDown. I was able to modify your code by adding a second event handler, PreviewMouseLeftButtonDown, which captured only the left click:
Thanks
Comment
-
This was a response to post #12 and was fixed in B3-B5... In B6 this seems to be broke again..Originally posted by NinjaTrader_Matthew View PostThe menu item was moving to another visual tree when collapsed. This scenario will be fixed in B3 where the extension method has been updated to find the menu item if it is collapsed.
Comment
-
Quote:
Originally Posted by NinjaTrader_Matthew
The menu item was moving to another visual tree when collapsed. This scenario will be fixed in B3 where the extension method has been updated to find the menu item if it is collapsed.
Originally posted by -=Edge=- View PostThis was a response to post #12 and was fixed in B3-B5... In B6 this seems to be broke again..
Can this be confirmed that this somehow got broke in B6?
Comment
-
No, I cannot reproduce based on the scenario in that post.
To test, I amended the indicator posted in #12 with the new chart trader automation id, "ChartWindowChartTraderControl" and I do not get any error sand works regardless of how the buttons are displayed.
Exactly where in the script is this logic breaking for you in B6?Attached FilesMatthewNinjaTrader Product Management
Comment
-
I guess I should have been a bit more specific.. Yes, this example works fine.. and all the menuitems seem to work fine.. Try casting "ChartWindowPropertiesButton" or any of the other buttons and I get the null reference when they are not visible in the toolbar..Originally posted by NinjaTrader_Matthew View PostNo, I cannot reproduce based on the scenario in that post. To test, I amended the indicator posted in #12 with the new chart trader automation id, "ChartWindowChartTraderControl" and I do not get any error sand works regardless of how the buttons are displayed.
Exactly where in the script is this logic breaking for you in B6?

Edit: Not VisibleLast edited by -=Edge=-; 11-05-2015, 08:23 AM.
Comment
-
Please Test This..Originally posted by NinjaTrader_Matthew View PostNo, I cannot reproduce based on the scenario in that post. Exactly where in the script is this logic breaking for you in B6?
Initially load this sample script with all toolbar items visible and an output window open.. Then do reload ninjascript couple times.. All is well.. (No Printed Output)
Now reduce the size of your chart horizontally so that the properties button is no longer visible and reload ninjascript again. The button now comes back null..
Although the menu items seem to all work fine when in the overflow, any/all of the buttons come back null.. Is this a bug, or am I possibly doing something wrong?
Attached Files
Comment
-
Just tryied to apply some code from that thread and looks like version 8.0.0.9 64-bit I have installed turns to be unresponsive when it rich the line
To be more correct the chart becomes unresponsive at all and the only way to close it is to kill the ninjatrader process in the task manager.Code:chartTrader = Window.GetWindow(ChartControl.Parent).FindFirst("ChartWindowChartTrader") as ChartTrader;
Does anybody use that? Does it work for you?
Comment
-
Hello,
Thank you for the question.
Is there further context to this single line or mainly is a Dispatcher being used? If so are you using BeginInvoke or Invoke? There have been changes recently that may cause a "deadlock" when Invoke is used instead of BeginInvoke. Could you check that this is not the case?
I see in the prior sample provided Invoke is used, so that would need to change to BeginInvoke to prevent this from occurring.
I look forward to being of further assistance.
Comment
-
Hi Jesse,
Thank you for your help. It was Invoke and changing it to BeginInvoke resolved the issue with deadlocking. But now chartTrader is always null. Probably Automation ID is no longer ChartWindowChartTrader. Not sure how to find out that.
I know that I am on unsupported area so will be greatful for any help or advise!
P.S. I have attached the sample I usedAttached Files
Comment
-
Hello,
It looks like you are missing the word "Control" from the string, it would be:It appears the thread has had the incorrect automation id posted, but in the prior example on post #23 it seems to be correct.ChartWindowChartTraderControl
Please use:
As a side note, if you are curious on how to find automation ids, there is a tool but unfortunately it requires that the windows 8.1 sdk be installed which is rather large.Code:chartTrader = Window.GetWindow(ChartControl.Parent).FindFirst("ChartWindowChartTraderControl") as ChartTrader;
Learn how to use Inspect, a Windows-based tool that can select any UI element and view its accessibility data.
I look forward to being of further assistance.
Comment
Latest Posts
Collapse
| Topics | Statistics | Last Post | ||
|---|---|---|---|---|
|
Started by Geovanny Suaza, 02-11-2026, 06:32 PM
|
0 responses
673 views
0 likes
|
Last Post
|
||
|
Started by Geovanny Suaza, 02-11-2026, 05:51 PM
|
0 responses
379 views
1 like
|
Last Post
|
||
|
Started by Mindset, 02-09-2026, 11:44 AM
|
0 responses
111 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
578 views
1 like
|
Last Post
|
||
|
Started by RFrosty, 01-28-2026, 06:49 PM
|
0 responses
582 views
1 like
|
Last Post
by RFrosty
01-28-2026, 06:49 PM
|

Comment