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!
See more
See less

Partner 728x90

Collapse

How to detect and fill a Quantity Selector field with hotkey from Ninajcsript alone

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    How to detect and fill a Quantity Selector field with hotkey from Ninajcsript alone

    I'm wondering if that would be possible in someway I can't grasp yet.

    I'm trying to find a way to create a Hotkey that would:
    1. detect the QuantitySelector field, focus the cursor in it, and then fill it with a value
    2. and then focus the cursor out of the Quantity Selector field and focus it on the Chart
    I know how to do it with a simple AutoHotKey script.

    But would it be possible to do it with a Ninjascript script directly? How would you handle the mouse cursor focus control part with Ninjascript code alone? Thanks!
    Last edited by PaulMohn; 06-20-2022, 08:23 AM.

    #2
    Hello PaulMohn,

    You can find a sample of accessing the quantity selector here: https://ninjatrader.com/support/foru...365#post736365

    To set its value you would use the instance of the quantity selector and set its value property.

    Other items like hotkeys would require using preview key events, you can find a sample of using preview key events on a control in the following post, a hotkey would need to go on the ChartControl object to avoid having to focus a specific control. If you want to learn about focus on specific controls you would need to use external C# WPF tutorials to learn those concepts.



    WPF Mouse events could be attached to the ChartControl object. You can learn about how WPF mouse and keyboard events work in external C# WPF tutorials.



    JesseNinjaTrader Customer Service

    Comment


      #3
      Hello Jesse and thank you for the direction and details.

      I found those preliminary resources
      https://docs.microsoft.com/en-us/dot...ktop-4.8#focus

      This one seems a simple enough solution I'd like to test
      Cursor Focus on Textbox in WPF/C#

      PHP Code:
      Dispatcher.BeginInvoke((ThreadStart)delegate
      {
        
      control.Focus();
      }); 

      Alternatively
      PHP Code:
      private void Button_Click(object senderRoutedEventArgs e)
      {
        
      textBox.Focus();
        
      textBox.SelectionStart textName.Text.Length;


      What would be the Ninjascript equivalent for the control. or textBox. ? How can I know what it would be? Thanks!


      I already have that previous QuantitySelector method working ready
      PHP Code:
            private void On_quantitySelector_PreviewKeyDown(object senderKeyEventArgs p)
            {
              
      NinjaTrader.Gui.Tools.QuantityUpDown qs sender as NinjaTrader.Gui.Tools.QuantityUpDown;

              if (
      p.Key == Key.Delete || p.Key == Key.Back)
              {
                
      p.Handled true;
                
      qs.Value 0;
              }

              if ((
      p.Key >= Key.D0 && p.Key <= Key.D9 || (p.Key >= Key.NumPad0 && p.Key <= Key.NumPad9)))
              {
                
      p.Handled true;

                
      string number p.Key.ToString();
                
      string newnumber qs.Value.ToString();

                
      number number.Replace("NumPad""");
                
      number number.Replace("D""");
                
      int num int.Parse(newnumber number);

                if (
      qs != nullqs.Value num;
              }
            } 

      Thanks!
      Last edited by PaulMohn; 06-07-2022, 12:44 PM.

      Comment


        #4
        Hello PaulMohn,

        There is not a NinjaScript equivalent for that code, you would use that code specifically. WPF is the window framework that NinjaTrader uses. If you want to focus a control then the control in question would be whatever control you have an instance of. I provided a link previously that shows finding the quantity selector, that is a control and an instance of that control. If you wanted to focus something else then you need an instance of whatever control you wanted to focus. Focus() is a method of a WPF control.







        JesseNinjaTrader Customer Service

        Comment


          #5
          Thanks for the further WPF points.
          I found further resources
          https://docs.microsoft.com/en-us/dot...orkdesktop-4.8

          https://www.codeproject.com/Question...-in-wpf-csharp

          https://stackoverflow.com/questions/...textbox-in-wpf




          However those examples and tutorials are for Textboxes and I couldn't find any for the quantitySelector.

          Thanks for your example

          I have it in my State.DataLoaded block
          PHP Code:
          ChartControl.Dispatcher.InvokeAsync((Action)(() =>
          {
               
          quantitySelector = (Window.GetWindow(ChartControl.Parent).FindFirst(" ChartTraderControlQuantitySelector") as NinjaTrader.Gui.Tools.QuantityUpDown);
          })); 

          I tested adding it to
          PHP Code:
                private void On_quantitySelector_PreviewKeyDown(object senderKeyEventArgs p)
                {
                  
          NinjaTrader.Gui.Tools.QuantityUpDown qs sender as NinjaTrader.Gui.Tools.QuantityUpDown;

                  if (
          p.Key == Key.Insert)
                  {
                    
          p.Handled true;
                    
          quantitySelector.Focus();
                  } 
          but it's not working.
          I get Log Tab errors
          Time Category Message
          07/06/2022 21:58:48 Order Failed to submit orders: System.NullReferenceException: Object reference not set to an instance of an object. at NinjaTrader.Cbi.Account.Submit(IEnumerable`1 orders)
          I also tested adding it as
          PHP Code:
          protected void ChartControl_PreviewKeyDown(object senderKeyEventArgs e)
          {
             
          TriggerCustomEvent(=>
             {
                if (
          Keyboard.IsKeyDown(Key.Insert))
                {
                   
          quantitySelector.Focus();
                }

             }, 
          null);
             
          e.Handled true

          But it's not working either.
          I get Log Tab errors
          Time Category Message
          07/06/2022 21:58:48 Order Failed to submit orders: System.NullReferenceException: Object reference not set to an instance of an object. at NinjaTrader.Cbi.Account.Submit(IEnumerable`1 orders)
          What is the quantitySelector control reference I must use instead of the textbox? Thanks!

          Your specific controls focus sample also shows only a textbox example


          I see it creates a TextBox class level variable line 35
          PHP Code:
          private TextBox textBox

          Then it adds it to the User Controls Collection lines 54-61
          PHP Code:
          Dispatcher.Invoke((() =>
          {
             
          textBox = new TextBox();

             
          textBox.PreviewKeyDown += TextBox_PreviewKeyDown;

             
          UserControlCollection.Add(textBox);
          })); 

          And finally it makes use of it in a custom PreviewKeyDown method lines 75-84
          PHP Code:
          private void TextBox_PreviewKeyDown(object senderKeyEventArgs e)
          {
             
          // this is pretty dumb, but should get you started
             // might want to validate this by using SHIFT or something
             // so Overlay Instrument Selector isn't unusable...
             
          TextBox textBoxSender = (TextBoxsender;
             
          textBoxSender.Text += e.Key.ToString();
             
          // handle the keydown event for the text box
             
          e.Handled true;


          My code adds the quantity Selector to the Toolbar, not the User Control Collection.

          How would I modify your TextBox control added to the User Control Collection example for a quantitySelector control in the Toolbar use? Thanks!
          Last edited by PaulMohn; 06-07-2022, 03:10 PM.

          Comment


            #6
            Hello PaulMohn,

            The quantity selector is a custom control in NinjaTrader however that just derives from a WPF Control so it has the same base methods. You wont find tutorials for NinjaTrader controls in regard to WPF, you would have to learn WPF concepts outside of NinjaTrader and then use the concepts you learn from the base WPF concepts if you need them for the NinjaTrader controls.

            I also tested adding it as
            quantitySelector.Focus();
            If you are trying to set a value you don't need to focus the control, just set a value to Value property on the control like the sample that I linked. you only need to focus a control for very specific reasons, it is infrequent that you would need to manually focus a control.

            What is the quantitySelector control reference I must use instead of the textbox? Thanks!
            If you mean the sample that was linked previously that is to show how to use PreviewKey events which is another WPF based concept. PreviewKey events are not part of NinjaScript/NinjaTrader but WPF, the TextBox in that sample is what the sample is using to demonstrate text entry and blocking the chart from its instrument search. If you wanted to detect keys on some other control you would use that control in place of the textbox. That sample just shows how to handle key events regardless of what WPF control is being used, if no input control is being used (hotkey) you can use ChartControl.

            For most the items you are asking about it would be greatly helpful to work on learning how to make WPF applications/use events in C#/etc. so that the creation of the controls and other UI elements in NinjaScript makes more sense. UI modifications you make are not going to be documented because you are just interfacing with the WPF application at that point. This is no different than running your own WPF application and making changes to the UI based on some logic in the applications code. Taking this step can greatly advance your ability to understand how items are used and manipulated in NinjaTrader.


            Object reference not set to an instance of an object. at NinjaTrader.Cbi.Account.Submit(IEnumerable`1 orders)
            This means an object was null, the error also states at the Submit method which I don't see in what you provided. If you are using Submit to submit an order then some part of that statement was null, either the account or order array.





            JesseNinjaTrader Customer Service

            Comment


              #7
              Thanks for the answer.
              I need to use the focus() feature for the following reason

              Currently I can only set the value after manually with the mouse getting the cursor focused on the Toolbar quantitySelector.

              Between trades, I'll change sizes. I need to focus the cursor on the Toolbar quantitySelector programatically before setting the value.
              my goal is to avoid having to use the mouse and only use hotkeys. Hope it's clear and makes sens somehow.
              Of course I'll add the setting value command afterwards to the new hotkey.

              I don't see what is the other control I should use. Since the control is already created in the ToolBar, I don't understand why calling it as I did doesn't work. Can you help on that specifically? Thanks!

              Attached the script. Thanks!
              Attached Files
              Last edited by PaulMohn; 06-07-2022, 03:34 PM.

              Comment


                #8
                PaulMohn Is this an accurate summary of what you want to achieve:
                1. Press a "hotkey" from anywhere on a Chart
                2. In response to that key being pressed, set a pre-defined value into the ChartTrader QuantitySelector
                3. Continue from wherever you were
                If that is so, you really only need to do this:
                1. Use a PreviewKey event to recognise the key press you want wherever you are -- this may mean you need to handle the event in multiple places so you capture it from wherever you are, or, to be simpler, ensure you are "on the chart" (or any other specific place you want) when you press the key
                2. Within the PreviewKey event handler, set the pre-defined value into the ChartTrader QuantitySelector using a simple assignment statement, as mentioned by NinjaTrader_Jesse above -- no focus on the actual QuantitySelector is needed; simply "set and forget"
                3. Continue where you were; again, no need to "re-focus" since you never changed the focus -- you simply responded to a key-press in the current control
                There's a bit of nuance to making sure that all works as intended, but it's not too complex. You'll need to be able to identify the control(s) you want to be able to recognise the key press and the QuantitySelector. That's really the crux of it.

                Thanks.
                Multi-Dimensional Managed Trading
                jeronymite
                NinjaTrader Ecosystem Vendor - Mizpah Software

                Comment


                  #9
                  Thanks jeronymite for the detailed explanation. I wasn't clear enough in my request I realize.

                  I don't use the ChartTrader QuantitySelector, instead I use a custom QuantitySelector located in the Toolbar
                  (here's a screenshot of the Chart with the Quantity Selector in the Toolbar


                  From this indicator
                  This Indicator is a 1st modification of the ClickLimitOrderIndicatorExpanded from NinjaTrader_Jim previous share Hot keys for order entry Combined with the 2nd PreviewKeyTest share Hot keys for order entry With kind help from Ninjatrader_Jesse and Ninjatrader_Chelsea from thread Set QuantityUpDown value from keyboard The Script Use: The basic script executes BuyMkt and SellMkt orders with [&#8230;]


                  And line 122-162 from this script
                  https://pastecode.io/s/t6g41a5i )

                  I need the focus feature to be able to change sizes with a hotkey instead of manually moving the mouse everytime to the QuantitySelector field.

                  The size won't be pre-set (I though first of using a pre-set size by simple assignment as you suggest, but that would multiply the number of Hotkeys.
                  I will have some pre-set hotkeys as well, but only a few vs the focus Hotkey).

                  My issue is I don't know and can't find how to access the QuantitySelector control reference from the Toolbar (or even from the ChartTrader).

                  My current code



                  I tested with quantitySelector.Focus(); references below snippets
                  130-142
                  337-396

                  lines
                  41-50
                  PHP Code:
                  private Chart chartWindow;


                  NinjaTrader.Gui.Tools.QuantityUpDown quantitySelector;

                  // QS
                  private bool Is_ToolBar_Controls_Added;

                  // QS https://stackoverflow.com/a/9301272/10789707
                  private int qs
                  84-122
                  PHP Code:
                          else if (State == State.Historical)
                          {
                            
                  //Call the custom addButtonToToolbar method in State.Historical to ensure it is only done when applied to a chart
                            // -- not when loaded in the Indicators window
                            
                  if (!Is_ToolBar_Controls_AddedAdd_Controls_To_Toolbar();
                          }
                          else if (
                  State == State.DataLoaded)
                          {
                            
                  // Find our account
                            
                  lock (Account.All)
                              
                  myAccount Account.All.FirstOrDefault(=> a.Name == AccountName);

                            if (
                  myAccount != null)
                              
                  myAccount.OrderUpdate += Account_OrderUpdate;

                            if (
                  ChartControl != null)
                            {
                              
                  ChartControl.PreviewKeyDown += ChartControl_PreviewKeyDown;


                              
                  ChartControl.Dispatcher.InvokeAsync((Action)(() =>
                              {
                                
                  quantitySelector = (Window.GetWindow(ChartControl.Parent).FindFirst(" ChartTraderControlQuantitySelector") as NinjaTrader.Gui.Tools.QuantityUpDown);
                              }));      
                            }
                          }
                          else if (
                  State == State.Terminated)
                          {
                            if (
                  myAccount != null)
                              
                  myAccount.OrderUpdate -= Account_OrderUpdate;

                            if (
                  ChartControl != null)
                            {
                              
                  ChartControl.PreviewKeyDown -= ChartControl_PreviewKeyDown;    
                            }

                            
                  //Call a custom method to dispose of any leftover objects in State.Terminated
                            
                  DisposeCleanUp();
                          }
                        } 
                  130-142
                  PHP Code:
                        protected void ChartControl_PreviewKeyDown(object senderKeyEventArgs e)
                        {


                          
                  TriggerCustomEvent(=>
                          {
                            if (
                  Keyboard.IsKeyDown(Key.Insert))
                            {
                              
                  quantitySelector.Focus();
                            }

                          }, 
                  null);
                          
                  e.Handled true
                  336-359
                  PHP Code:
                        private void Add_Controls_To_Toolbar()
                        {
                          
                  // Use this.Dispatcher to ensure code is executed on the proper thread
                          
                  ChartControl.Dispatcher.InvokeAsync((Action)(() =>
                          {
                            
                  //Obtain the Chart on which the indicator is configured
                            
                  chartWindow Window.GetWindow(this.ChartControl.Parent) as Chart;
                            if (
                  chartWindow == null)
                            {
                              Print(
                  "chartWindow == null");
                              return;
                            }

                            
                  quantitySelector = new NinjaTrader.Gui.Tools.QuantityUpDown();
                            
                  //quantitySelector.ValueChanged += On_quantitySelector_ValueChanged;
                            
                  quantitySelector.PreviewKeyDown   += On_quantitySelector_PreviewKeyDown;

                            
                  chartWindow.MainMenu.Add(quantitySelector);

                            
                  Is_ToolBar_Controls_Added true;

                            
                  quantitySelector.Value 1;

                          }));
                        } 
                  337-396
                  PHP Code:
                        private void On_quantitySelector_PreviewKeyDown(object senderKeyEventArgs p)
                        {
                          
                  NinjaTrader.Gui.Tools.QuantityUpDown qs sender as NinjaTrader.Gui.Tools.QuantityUpDown;

                  //       if (p.Key == Key.Insert)
                  //       {
                  //         p.Handled = true;
                  //         quantitySelector.Focus();
                  //       }

                          
                  if (p.Key == Key.Delete || p.Key == Key.Back)
                          {
                            
                  p.Handled true;
                            
                  quantitySelector.Value 0;
                          }

                          if ((
                  p.Key >= Key.D0 && p.Key <= Key.D9 || (p.Key >= Key.NumPad0 && p.Key <= Key.NumPad9)))
                          {
                            
                  p.Handled true;

                            
                  string number p.Key.ToString();
                            
                  string newnumber qs.Value.ToString();

                            
                  number number.Replace("NumPad""");
                            
                  number number.Replace("D""");
                            
                  int num int.Parse(newnumber number);

                            if (
                  qs != nullqs.Value num;
                          }

                        } 
                  Those 2 tests don't work. I think it is because quantitySelector.Focus() isn't the correct control reference.
                  Since the quantity selector is an internal to NT8 control (I guess, the doc and doc1 isn't helpful to know), I can't guess what other control/control path to reference. Do you have any idea how to find what control to use?


                  I did extensive research and testing about controls but I can't infer what the control would be.

                  Control Class (System.Windows.Controls) | Microsoft Docs

                  UIElement.PreviewKeyDown Event (System.Windows) | Microsoft Docs

                  UIElement.Focus Method (System.Windows) | Microsoft Docs

                  Programmatically Select A Tab By ActualName - NinjaTrader Support Forum

                  WPF - Controls

                  Set current window focus - NinjaTrader Support Forum

                  Strategy control its Ninja Chart keyboard focus? - NinjaTrader Support Forum

                  OnKeyDown does not fire coming from lost focus window - NinjaTrader Support Forum

                  c# - WPF TextBox Move Cursor and Change Focus - Stack Overflow

                  How To Set Focus On TextBox In C# Windows Forms | All Possible Cases - YouTube

                  Textbox Set Cursor Focus and Enter Key Handling in c# - YouTube

                  [Solved] Cursor position in a text box in wpf c# - CodeProject

                  Set the caret/cursor position to the end of the string value WPF textbox - Stack Overflow

                  How to set cursor focus to a textbox? - CodeProject

                  How to set cursor focus on wpf usercontrol's textbox. - CodeProject

                  Focus Overview

                  Referencing MainTabControl.Items.Count - NinjaTrader Support Forum

                  NT8 sendkeys

                  SendKeys Use with NT8 - NinjaTrader Support Forum

                  Window Activation Headaches in WPF - Rick Strahl's Web Log

                  How to*determine if the current chart is the active chart? - NinjaTrader Support Forum

                  The closest/simplest answers I found are


                  Hi, I'm developing a &quot;standalone&quot; unmanaged strategy which has its own Winforms interface. Yes, I know about WPF but this older approach is, for me at least, an easier approach, and it's working fine. But since the strategy is started by, and associated with a NinjaTrader &quot;host&quot; Chart, and I'm wanting to use




                  For example below the tab. Focus() worked here
                  PHP Code:
                      chart Window.GetWindow(ChartControl) as Chart;
                      foreach (
                  System.Windows.Controls.TabItem tab in chart.MainTabControl.Items)
                      {
                      if (
                  tab.Header.ToString() == Instrument.FullName)
                      {
                        
                  tab.Focus();
                        break;
                      }
                      } 
                  If so what equivalent control/control path for the quantitySelector would be required?
                  Thanks!

                  Comment


                    #10
                    Hello PaulMohn,


                    My issue is I don't know and can't find how to access the QuantitySelector control reference from the Toolbar (or even from the ChartTrader).
                    You would use the variable you have to access the control you made:

                    Code:
                    [B]quantitySelector[/B].Focus();
                    I need the focus feature to be able to change sizes with a hotkey instead of manually moving the mouse everytime to the QuantitySelector field.
                    To set a value on the quantity selector you would set the selector property in code, there is no need to focus the control to set its properties through its variable quantitySelector.

                    Those 2 tests don't work. I think it is because quantitySelector.Focus() isn't the correct control reference.
                    What specifically didn't work? From what I can see you are just focusing the control, that wont have any visible change in the UI to know its focused. That also focuses the control, if you mean to type in that controls text box you would have to focus the child text box inside of that control so you would have to drill down into that control to be able to find that, That's really outside of what our support could assist with, you could research how WPF controls are created using multiple base controls and how they are structured to get a better idea of how to find child controls within another parent control.

                    To otherwise set a value to this control you could just use its value property quantitySelector.Value = 10;




                    JesseNinjaTrader Customer Service

                    Comment


                      #11
                      Hello Jesse and thanks for the needed info
                      if you mean to type in that controls text box you would have to focus the child text box inside of that control so you would have to drill down into that control to be able to find that
                      , that was what I was missing.

                      I found a working solution using the WPF class ChildControls and Loop through the Children shared here
                      PHP Code:
                      protected void ChartControl_PreviewKeyDown(object senderKeyEventArgs e)
                      {
                        
                      TriggerCustomEvent(=>
                        {
                        
                      ChildControls ccChildren = new ChildControls();

                        if (
                      Keyboard.IsKeyDown(Key.Insert))
                        {
                                  foreach (
                      object o in ccChildren.GetChildren(quantitySelector5))
                                {
                                    if (
                      o.GetType() == typeof(TextBox))
                                    {
                                        
                      TextBox txt = (TextBox)o;
                      //                 txt.Text = "2";
                                        
                      txt.Focus();
                                    }
                                }
                        }

                        }, 
                      null);
                        
                      e.Handled true
                      PHP Code:
                      namespace NinjaTrader.NinjaScript.Indicators
                      {
                          public class 
                      ProfitSniper Indicator
                          
                      {
                              
                      // The Main Indicator Code Here
                          
                      }

                          public class 
                      ChildControls
                          
                      {
                              private List<
                      objectlstChildren;

                              public List<
                      objectGetChildren(Visual p_vParentint p_nLevel)
                              {
                                  if (
                      p_vParent == null)
                                  {
                                      throw new 
                      ArgumentNullException("Element {0} is null!"p_vParent.ToString());
                                  }

                                  
                      this.lstChildren = new List<object>();

                                  
                      this.GetChildControls(p_vParentp_nLevel);

                                  return 
                      this.lstChildren;

                              }

                              private 
                      void GetChildControls(Visual p_vParentint p_nLevel)
                              {
                                  
                      int nChildCount VisualTreeHelper.GetChildrenCount(p_vParent);

                                  for (
                      int i 0<= nChildCount 1i++)
                                  {
                                      
                      Visual v = (Visual)VisualTreeHelper.GetChild(p_vParenti);

                                      
                      lstChildren.Add((object)v);

                                      if (
                      VisualTreeHelper.GetChildrenCount(v) > 0)
                                      {
                                          
                      GetChildControls(vp_nLevel 1);
                                      }
                                  }
                              }
                          }


                      I also had to add the
                      PHP Code:
                      using System.Windows.Controls

                      reference to the using declaration region for the TextBox to work.

                      Now it does focus as expected. I'll share the new indicator's version in the User Apps Share asa. many thanks again!

                      Alternative on Children
                      Addon getting the right ChartControl - Forum - NinjaTrader
                      Last edited by PaulMohn; 06-09-2022, 01:51 PM.

                      Comment


                        #12
                        Hello Jesse,

                        I'm trying to do the following
                        With a hotkey, Focus out of the QuantitySelector TextBox aand focus back into the Chart window.

                        I found this thread about it
                        Find Chart Windows - NinjaTrader Support Forum

                        I've tested this
                        PHP Code:
                          // FOCUS on Chart's Window
                          
                        TriggerCustomEvent(=>
                          {
                              if (
                        Keyboard.IsKeyDown(Key.Insert) && (Keyboard.IsKeyDown(Key.LeftCtrl) || Keyboard.IsKeyDown(Key.RightCtrl)))
                              {
                                  var 
                        cWind Window.GetWindow(this.ChartControl.Parent) as Chart;

                                  
                        ChartControl.Dispatcher.InvokeAsync(() =>
                                  {
                                      
                        cWind.Activate();
                                  });
                              }

                          }, 
                        null);
                          
                        e.Handled true
                        and this
                        PHP Code:
                          // FOCUS on Chart's Window
                          
                        TriggerCustomEvent(=>
                          {
                              if (
                        Keyboard.IsKeyDown(Key.Insert) && (Keyboard.IsKeyDown(Key.LeftCtrl) || Keyboard.IsKeyDown(Key.RightCtrl)))
                              {
                                  var 
                        cWind Window.GetWindow(this.ChartControl.Parent) as Chart;

                                  
                        ChartControl.Dispatcher.InvokeAsync(() =>
                                  {
                                      
                        cWind.Focus();
                                  });
                              }

                          }, 
                        null);
                          
                        e.Handled true

                        but it's not focusing out of the quantitySelector TextBox.

                        What's the correction you suggest to refocus on the Chart's window from out of the quantitySelector's TextBox? Thanks!

                        Comment


                          #13
                          Hello PaulMohn,

                          You could try to focus the ChartControl its self, otherwise I would not be sure what actual sub control is focused when using the mouse on the chart. Focus is the only method which would be used to control the focus on a specific control.



                          JesseNinjaTrader Customer Service

                          Comment


                            #14
                            Thanks for the suggestion. Do you mean that way?

                            PHP Code:
                              // FOCUS on Chart's Window
                              
                            TriggerCustomEvent(=>
                              {
                                  if (
                            Keyboard.IsKeyDown(Key.Insert) && (Keyboard.IsKeyDown(Key.LeftCtrl) || Keyboard.IsKeyDown(Key.RightCtrl)))
                                  {
                                      
                            ChartControl.Dispatcher.InvokeAsync(() =>
                                      {
                                          
                            ChartControl.Focus();
                                      });
                                  }

                              }, 
                            null);
                              
                            e.Handled true

                            I just tested but that's not working. Any other working direction? Thanks!

                            Comment


                              #15
                              Hello PaulMohn,

                              Yes that is what I was referring to, that is the only documented chart control so that would be the only item I could suggest. You can try to also focus the window but I am not certain if that would help. The focus may be coming from a sub control similar to how the text box is within the quantity control.

                              JesseNinjaTrader Customer Service

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by Sebastian - TwinPeaks, Yesterday, 01:31 PM
                              2 responses
                              12 views
                              0 likes
                              Last Post Sebastian - TwinPeaks  
                              Started by wbennettjr, 07-15-2017, 05:07 PM
                              16 responses
                              2,527 views
                              1 like
                              Last Post eladlevi  
                              Started by Human#102, Yesterday, 09:54 AM
                              2 responses
                              7 views
                              0 likes
                              Last Post Human#102  
                              Started by Patlpp, 08-16-2021, 03:10 PM
                              10 responses
                              498 views
                              0 likes
                              Last Post Joerg
                              by Joerg
                               
                              Started by AdamDJ8, 05-07-2024, 09:18 PM
                              2 responses
                              19 views
                              0 likes
                              Last Post -=Edge=-  
                              Working...
                              X