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

Add-On-Dev: adding new keyboard entry/handled problem

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

    Add-On-Dev: adding new keyboard entry/handled problem

    Hi.

    There is another problem with my add-on developement. I added a new QuantityUpDown-Element into an the default entry page. If I try to use the keyboard to change the value, nothing happens - instead the symbol selector gets triggered and shows up.

    How can I prevent the dialog to appear with inserted QuantityUpDown-elements?

    The two additional elements:

    Click image for larger version

Name:	a.jpg
Views:	126
Size:	61.4 KB
ID:	1185701


    When I press any key, e.g. the number 1 inside of the QuantityUpDown-element, the instrument-selector screen is shown:

    Click image for larger version

Name:	b.jpg
Views:	91
Size:	81.3 KB
ID:	1185702


    This means, the key is not handled by the control, instead the instrument selector picks it up.
    The other entry fields in the default entry window do not have this behavior. So which flag do I need to set to allow the processing of keys with the inserted elelemt?

    Best,
    Carsten






    #2
    Hi hiikila, thanks for posting.

    You need to attach the PreviewKeyDown event in the script to process the input. There is an example of this for a TextBox here:



    Change the type to NinjaTrader.Gui.Tools.QuantityUpDown instead e.g.

    using System.Windows.Input;

    public void TextBox_PreviewKeyDown(object sender, KeyEventArgs e)
    {
    NinjaTrader.Gui.Tools.QuantityUpDown textBoxSender = (NinjaTrader.Gui.Tools.QuantityUpDown) sender;
    textBoxSender.Value = (int)e.Key;
    // handle the keydown event for the text box
    e.Handled = true;
    }

    It must be noted that there are a few things left unhandled here, like the input will not take more than 1 number, the Delete key is not being handled, text input is not being ignored, and so on. All of the input needs to be handled in a custom way using PrievewKeyDown.

    Kind regards,
    -ChrisL
    Chris L.NinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by Kaledus, Today, 01:29 PM
    0 responses
    3 views
    0 likes
    Last Post Kaledus
    by Kaledus
     
    Started by PaulMohn, Today, 12:36 PM
    1 response
    16 views
    0 likes
    Last Post NinjaTrader_Gaby  
    Started by yertle, Yesterday, 08:38 AM
    8 responses
    37 views
    0 likes
    Last Post ryjoga
    by ryjoga
     
    Started by rdtdale, Today, 01:02 PM
    1 response
    6 views
    0 likes
    Last Post NinjaTrader_LuisH  
    Started by alifarahani, Today, 09:40 AM
    3 responses
    19 views
    0 likes
    Last Post NinjaTrader_Jesse  
    Working...
    X