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 GussJ, 03-04-2020, 03:11 PM
          16 responses
          3,281 views
          0 likes
          Last Post Leafcutter  
          Started by WHICKED, Today, 12:45 PM
          2 responses
          19 views
          0 likes
          Last Post WHICKED
          by WHICKED
           
          Started by Tim-c, Today, 02:10 PM
          1 response
          9 views
          0 likes
          Last Post NinjaTrader_ChelseaB  
          Started by Taddypole, Today, 02:47 PM
          0 responses
          5 views
          0 likes
          Last Post Taddypole  
          Started by chbruno, 04-24-2024, 04:10 PM
          4 responses
          53 views
          0 likes
          Last Post chbruno
          by chbruno
           
          Working...
          X