Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

Partner 728x90

Collapse

NumericTextBox Not Accepting Input

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

    NumericTextBox Not Accepting Input

    Hi again.

    Attached an addon that adds a numeric text box to the chart trader. Problem is that I can't type anything in the box.

    Also how would I go about removing the small 'Qty Pad' in the quantity up down control? I've tried setting the style to null but it doesn't work for this control.

    I like that it has built in mouse wheel support so I don't have to manage the events myself, and also the up and down buttons are useful, but when adding it to a chart trader the Qty Pad is taking up too much space in my layout.

    Thanks
    Attached Files

    #2
    Hello anon84,

    The script provided is not a working script. This doesn't do anything but declare a few variable types.

    Below are links to examples of modifying WPF elements Keep in mind, support for custom code like this is undocumented and outside of the realm of what is supported by N\injaTrader Support.
    http://ninjatrader.com/support/forum...327#post499327
    https://ninjatrader.com/support/foru...756#post831756
    http://ninjatrader.com/support/forum/showthread.php?p=515555#post515555
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      It does work. It's an addon.

      Comment


        #4
        Hello anon84,

        My mistake, I missed the TestBox = new NumericTextBox(); line.

        I'm uncertain about this WPF object type. Is the Instrument Overlay Selector appearing when you are typing in this?


        This thread will remain open for any community members that would like to assist with this custom C# code.

        You can also contact a professional NinjaScript Consultant who would be eager to create or modify this script at your request or assist you with your script. The NinjaTrader Ecosystem has affiliate contacts who provide educational as well as consulting services. Please let me know if you would like our business development follow up with you with a list of affiliate consultants who would be happy to create this script or any others at your request.

        Chelsea B.NinjaTrader Customer Service

        Comment


          #5
          For anyone interested, I figured out how to remove the Quantity Pad.

          By default the QtyPad button is at child index 3, so you can remove it like this:

          Code:
          ((QtyUpDn.Content as Border).Child as Grid).Children.RemoveAt(3);
          Fine for personal use, but if another script has modified the control then the index may be wrong.
          Safer method:

          Code:
          Grid grid = (QtyUpDn.Content as Border).Child as Grid;
          foreach(FrameworkElement fe in grid.Children)
          {
              if(fe.ToolTip == NinjaTrader.Gui.Resource.GuiQtyPad){ grid.Children.Remove(fe); break; }
          }
          Seemingly the only way to be sure that the item is the QtyPad button is to check the tooltip text.
          That text changes depending on the user's language settings though, so you have to compare via
          NinjaTrader.Gui.Resource.GuiQtyPad which returns the localized string equivalent of "Qty Pad".

          Comment


            #6
            Hi

            No, when typing simply nothing happens. The input gets eaten by something.

            This control works in the AddonFramework example, so I am not sure what is happening when it's added to ChartTrader.

            * Also NumericTextBox appears to be an NT custom control in the namespace NinjaTrader.Gui.Tools - NumericTextBox
            So I thought you'd have an idea of what was going on.

            ** I tested adding an official WPF TextBox and in that case typing does indeed get eaten by the instrument overlay selector.
            Maybe that will help you diagnose the issue with your NumericTextBox variant.
            Last edited by anon84; 05-13-2019, 11:31 AM.

            Comment


              #7
              Hi. Any updates about the issue? I am facing the same problem.

              Originally posted by anon84 View Post
              ** I tested adding an official WPF TextBox and in that case typing does indeed get eaten by the instrument overlay selector.
              As I understand, to prevent that, I can just add "OnKeyDown" event handler and set second (RoutedEventArgs) argument's property "Handled" to true. But how can I get the value of the text field? Does the "RoutedEventArgs rea" argument contain any info about user input?

              Comment


                #8
                Hello,

                I'm understanding you would like to prevent the instrument overlay selector from appearing.

                There is an example that demonstrates this.
                https://ninjatrader.com/support/foru...756#post831756
                Chelsea B.NinjaTrader Customer Service

                Comment


                  #9
                  Thanks for an answer. The example shows just how to prevent the event bubbling. But the Textbox field in the example is completely unusable. How to make it work as normal Textbox that accepts normal user input?

                  Comment


                    #10
                    Hello alvik48,

                    The text box can be typed in. Below is a link to a video that demonstrates.
                    https://drive.google.com/file/d/1bjT...w?usp=drivesdk

                    If the text box can be typed in, can you clarify how this 'unusable'?
                    Chelsea B.NinjaTrader Customer Service

                    Comment


                      #11
                      Sure. The default textbox behaviour is completely different In the example after each key pressed the code of key (not the original char!) adds to the textbox content. But default behaviour is much more complex: it should add right chars, it should react on cursor moves, highlighting, deleting chars (forwards and backwards) and so on. That what I want from the custom textbox. And I think that manual implementation of the full default logic is not a good idea because it should just work from the box, I just can't understand how.

                      Comment


                        #12
                        Hello alvik48,

                        Are you saying there are characters on your keyboard that can't be typed into the textbox with the example I provided?

                        What cursor moves are you referring to?
                        Chelsea B.NinjaTrader Customer Service

                        Comment


                          #13
                          Hmm, it is really interesting that you are asking me that. Okay, let me explain:

                          I am entering "1", then - backspace. I expect that after first typing I will see "1" in the textbox, after second one - empty string.

                          What happens: after first typing I see "D1", after second - "D1Back".

                          I hope I explained the issue. How to make the textbox to work like any normal textbox?

                          Comment


                            #14
                            Hello alvik48,

                            Capture the Backspace key (Keys.Back) and remove the last character from the textbox.

                            As this is not documented or supported by NinjaTrader, I am including a link to a 3rd party educational site.
                            https://stackoverflow.com/questions/...keypress-event
                            Chelsea B.NinjaTrader Customer Service

                            Comment


                              #15
                              So you are suggesting me to implement the default textbox behaviour manually (I should manually handle not only backspace, but also all the control buttons, also I need to convert char codes into original chars and so on). It looks at least strange, because it should work by default! I believe that a normal solution exists.

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by 309338, Today, 12:06 PM
                              0 responses
                              11 views
                              0 likes
                              Last Post 309338
                              by 309338
                               
                              Started by AaronKoRn, Yesterday, 08:38 PM
                              2 responses
                              52 views
                              0 likes
                              Last Post NinjaTrader_ChrisL  
                              Started by rocketstock, 08-05-2022, 09:36 PM
                              2 responses
                              77 views
                              0 likes
                              Last Post NinjaTrader_ChrisL  
                              Started by ronyggg83, Yesterday, 03:48 PM
                              4 responses
                              54 views
                              0 likes
                              Last Post NinjaTrader_ChelseaB  
                              Started by preqc, 08-05-2022, 09:10 AM
                              1 response
                              40 views
                              0 likes
                              Last Post NinjaTrader_Jim  
                              Working...
                              X