Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Inputting text to an indicator

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

    Inputting text to an indicator

    One of my indicators has a custom menu to toggle different properties

    The toggles all work great however I'm having issues in trying to get a text input and wondering if you have any suggestions

    The issue: when I select the text box and try to edit it, if I type any key NT takes over and thinks I'm trying to load a new data series or Instrument.

    When I add a NTMenuItem to another NTMenuItem I get the multiple levels, but I've tried adding the following to the NTMenuItem with no luck on registering the key presses

    TextBox() - NT window grabs key press before it can (space and backspace key work without issue)

    QuantityUpDown() - using the up down I can get a value but this isn't a reasonable solution

    NumericTextBox() - gets errors when trying to edit text
    "Unhandled Exception: Object reference not set to an instance of an object"
    Attached Files
    Last edited by HandsFreeTrader; 04-06-2016, 12:54 PM.

    #2
    Hello HandsFreeTrader,

    Thank you for writing in.

    In order to prevent the chart's text box for loading a new instrument or time period to appear while trying to type into your text box, you'll need to create an event handler method.

    As an example:
    Code:
    private void TextBox_KeyDown(object sender, KeyEventArgs e)
    {
         e.Handled = true;
         TextBox textBoxSender = (TextBox)sender;
    
         textBoxSender.Text += e.Key;
         theTextBox.SelectionStart = theTextBox.Text.Length;
    }
    You'll then need to subscribe to this event handler method with your text box's KeyDown event.

    As an example:
    Code:
    private TextBox theTextBox;
    
    theTextBox = new TextBox();
    theTextBox.KeyDown += TextBox_KeyDown;
    The event handler method will prevent the chart's text box from appearing.

    Ensure to unsubscribe in State.Terminated with -=.

    Please, let us know if we may be of further assistance.
    Zachary G.NinjaTrader Customer Service

    Comment


      #3
      Thanks the KeyDown saved me as I had tried others such as input and textchanged but not KeyDown.

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by Jonafare, 12-06-2012, 03:48 PM
      5 responses
      3,984 views
      0 likes
      Last Post rene69851  
      Started by Fitspressorest, Today, 01:38 PM
      0 responses
      2 views
      0 likes
      Last Post Fitspressorest  
      Started by Jonker, Today, 01:19 PM
      0 responses
      2 views
      0 likes
      Last Post Jonker
      by Jonker
       
      Started by futtrader, Today, 01:16 PM
      0 responses
      6 views
      0 likes
      Last Post futtrader  
      Started by Segwin, 05-07-2018, 02:15 PM
      14 responses
      1,791 views
      0 likes
      Last Post aligator  
      Working...
      X