Announcement

Collapse
No announcement yet.

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:	157
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:	114
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

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by Geovanny Suaza, 02-11-2026, 06:32 PM
    0 responses
    558 views
    0 likes
    Last Post Geovanny Suaza  
    Started by Geovanny Suaza, 02-11-2026, 05:51 PM
    0 responses
    324 views
    1 like
    Last Post Geovanny Suaza  
    Started by Mindset, 02-09-2026, 11:44 AM
    0 responses
    101 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Started by Geovanny Suaza, 02-02-2026, 12:30 PM
    0 responses
    546 views
    1 like
    Last Post Geovanny Suaza  
    Started by RFrosty, 01-28-2026, 06:49 PM
    0 responses
    547 views
    1 like
    Last Post RFrosty
    by RFrosty
     
    Working...
    X