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:	168
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:	124
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 DannyP96, 05-18-2026, 02:38 PM
    1 response
    85 views
    0 likes
    Last Post NinjaTrader_ChelseaB  
    Started by CarlTrading, 05-11-2026, 05:56 AM
    0 responses
    143 views
    0 likes
    Last Post CarlTrading  
    Started by CarlTrading, 05-10-2026, 08:12 PM
    0 responses
    83 views
    0 likes
    Last Post CarlTrading  
    Started by Hwop38, 05-04-2026, 07:02 PM
    0 responses
    256 views
    0 likes
    Last Post Hwop38
    by Hwop38
     
    Started by Mindset, 04-21-2026, 06:46 AM
    0 responses
    334 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Working...
    X