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 terofs, Yesterday, 04:18 PM
      1 response
      21 views
      0 likes
      Last Post terofs
      by terofs
       
      Started by CommonWhale, Today, 09:55 AM
      1 response
      3 views
      0 likes
      Last Post NinjaTrader_Erick  
      Started by Gerik, Today, 09:40 AM
      2 responses
      7 views
      0 likes
      Last Post Gerik
      by Gerik
       
      Started by RookieTrader, Today, 09:37 AM
      2 responses
      13 views
      0 likes
      Last Post RookieTrader  
      Started by alifarahani, Today, 09:40 AM
      1 response
      7 views
      0 likes
      Last Post NinjaTrader_Jesse  
      Working...
      X