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 mjairg, 07-20-2023, 11:57 PM
      3 responses
      213 views
      1 like
      Last Post PaulMohn  
      Started by TheWhiteDragon, 01-21-2019, 12:44 PM
      4 responses
      544 views
      0 likes
      Last Post PaulMohn  
      Started by GLFX005, Today, 03:23 AM
      0 responses
      3 views
      0 likes
      Last Post GLFX005
      by GLFX005
       
      Started by XXtrader, Yesterday, 11:30 PM
      2 responses
      12 views
      0 likes
      Last Post XXtrader  
      Started by Waxavi, Today, 02:10 AM
      0 responses
      7 views
      0 likes
      Last Post Waxavi
      by Waxavi
       
      Working...
      X