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 Geovanny Suaza, 02-11-2026, 06:32 PM
      0 responses
      657 views
      0 likes
      Last Post Geovanny Suaza  
      Started by Geovanny Suaza, 02-11-2026, 05:51 PM
      0 responses
      373 views
      1 like
      Last Post Geovanny Suaza  
      Started by Mindset, 02-09-2026, 11:44 AM
      0 responses
      109 views
      0 likes
      Last Post Mindset
      by Mindset
       
      Started by Geovanny Suaza, 02-02-2026, 12:30 PM
      0 responses
      574 views
      1 like
      Last Post Geovanny Suaza  
      Started by RFrosty, 01-28-2026, 06:49 PM
      0 responses
      579 views
      1 like
      Last Post RFrosty
      by RFrosty
       
      Working...
      X