Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Disable Quick time period change dialog

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

    Disable Quick time period change dialog

    I have a textbox in my Mainmenu, when I enter text in that area, the quick time period change dialog pops up and I can't edit my textbox.

    Ninjatrader Matt showed me some code here:


    however, I want to be able to press delete / backspace and have it function like a normal textbox. I'm using the following code right now as a workaround, but i can only append text to the end. What is the proper way to accomplish this?

    Code:
    private void TextBox_PreviewKeyDown(object sender, KeyEventArgs e)
    		{
    			
    			TextBox textBoxSender = (TextBox) sender;
    			if(e.Key >= Key.D0 && e.Key <= Key.D9 || (e.Key >= Key.NumPad0 && e.Key <= Key.NumPad9)) { 
    				string s = e.Key.ToString();
    				textBoxSender.Text += s.Substring(s.Length-1,1);
    			// handle the keydown event for the text box
    			e.Handled = true;
    			}
    			
    			
    			
    		}

    #2
    Hello habibalex,

    Thank you for your post.

    So I may understand what you are looking for in the end, can you answer the following?
    Do you need the text box inside of the chart and panel? Can it it be a "window" outside of chart?
    Are Delete and Backspace the only functions you would need inside the text box?

    Comment


      #3
      I need the textbox on the MainMenu of the chart because I'm changing values.
      Delete and backspace are the only functions I need.

      I would just expect that I can edit the textbox like a normal textbox since I am inside that textbox, not the main chart window.

      Comment


        #4
        Hello habibalex,

        Thank you for your patience.

        Attached is an example of a text box added to the toolbar that will preview the key down and allow for functions like Backspace, Delete, Left and Right to work.

        Please let me know if you have any questions.
        Attached Files

        Comment


          #5
          in case someone wants to use this in the future, it doesn't work well. It still only appends to the end of the string and pressing shift left / right arrow does nothing. You also need to add the code from my first post to get numbers and then handle the decimal key separately. Either way its a real pain to enter stuff into textboxes in NT8. If you have an idea of the kind of values you need to enter, just capture mouse wheel events and scroll thru them


          Code:
          private void button_MouseWheel(object s, MouseWheelEventArgs e)
                  {
                      TextBox b = (TextBox)s;
                      int val = Convert.ToInt32(b.Text);
          			int factor = 100;
          			if((Keyboard.Modifiers & ModifierKeys.Control) > 0) factor = 1;
                      val += (int)Math.Round( e.Delta / 120.0)*factor;
          			val = Math.Max(0,val);
                      b.Text = val.ToString();
                  }

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by algospoke, 04-17-2024, 06:40 PM
          3 responses
          26 views
          0 likes
          Last Post NinjaTrader_Jesse  
          Started by bmartz, 03-12-2024, 06:12 AM
          3 responses
          30 views
          0 likes
          Last Post NinjaTrader_Zachary  
          Started by Aviram Y, Today, 05:29 AM
          2 responses
          10 views
          0 likes
          Last Post Aviram Y  
          Started by gentlebenthebear, Today, 01:30 AM
          1 response
          8 views
          0 likes
          Last Post NinjaTrader_Jesse  
          Started by cls71, Today, 04:45 AM
          1 response
          7 views
          0 likes
          Last Post NinjaTrader_ChelseaB  
          Working...
          X