London
Experience: None
Platform: ninjatrader
Trading: ftse100
Posts: 67 since Sep 2017
Thanks Given: 11
Thanks Received: 23
|
Hi,
I've also posted this on the NT8 help forum but thought you guys might also know the answer to this.
In a situation where I have multiple windows with multiple tabs open on each window, I am trying to have code within an indicator that will find and focus on the tab with the indicator running then use the SendKey.Wait method.
I am unable to get the tab to become focussed in the first instance.
I am using .Focus() within a dispatcher then checking using .IsFocused however I cannot get IsFocused to become true.
Can anyone suggest the correct use of code to focus on the tab with the indicator running please.I am trying the code below but IsFocussed is still coming out as false.
Thanks for any suggestions
_____________________________________________________________________________________
private NinjaTrader.Gui.Chart.ChartTab chartTab;
private Chart chartWindow;
private System.Windows.Controls.TabItem tabItem;
protected override void OnBarUpdate()
{
ChartControl.Dispatcher.InvokeAsync((Action)(() =>
{
chartWindow = Window.GetWindow(this.ChartControl.Parent) as Chart;
if(chartWindow==null)
{
Print("chartWindow== null");
return;
}
foreach (System.Windows.Controls.TabItem tab in chartWindow.MainTabControl.Items)
if ((tab.Content as ChartTab).ChartControl == ChartControl && tab == chartWindow.MainTabControl.SelectedItem)
tabItem=tab;
if (tabItem == null)
return;
chartTab = tabItem.Content as NinjaTrader.Gui.Chart.ChartTab;
if (chartTab == null)
return;
chartTab.Focus();
Print(chartTab.IsFocused);
}));
}
|