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 carnitron, Today, 08:42 PM
      0 responses
      6 views
      0 likes
      Last Post carnitron  
      Started by strategist007, Today, 07:51 PM
      0 responses
      8 views
      0 likes
      Last Post strategist007  
      Started by StockTrader88, 03-06-2021, 08:58 AM
      44 responses
      3,974 views
      3 likes
      Last Post jhudas88  
      Started by rbeckmann05, Today, 06:48 PM
      0 responses
      9 views
      0 likes
      Last Post rbeckmann05  
      Started by rhyminkevin, Today, 04:58 PM
      4 responses
      58 views
      0 likes
      Last Post dp8282
      by dp8282
       
      Working...
      X