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

Intercept keyboard event and trigger

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

    Intercept keyboard event and trigger

    Hi,

    after trying to implement something for a long time and failing to do so, unfortunately I have to ask for help.
    I hope somone can help me.

    My goal is to create a script to move the chart from the program.
    Since I did not find anything in the documentation, I would like to use C# Event, the
    Left and right arrow triggers.


    Code:
    protected override void OnStateChange()
    {
        if (State == State.DataLoaded)
        {
            this.ChartPanel.KeyDown += new System.Windows.Input.KeyEventHandler(OnKeyDown);          
        }
        else if (State == State.Terminated)
        {
            this.ChartPanel.KeyDown -= OnKeyDown;          
        }
    }
    
    public void OnKeyDown(object sender, System.Windows.Input.KeyEventArgs e)
    {   
        // detect Key (23 Left) and (25 Right)?
        Print("Down");     
    }
    example, not working


    Unfortunately, after 8 hours of programming, I am not getting anywhere.
    Can someone help me and tell me:

    A, how to intercept the keyboard event?
    B. That can act as a trigger?

    #2
    Hello,

    You can find a sample of using key events in the linked post below. As this is not NinjaScript specific you won't find much information about using WPF key events here on the forum or in the help guide. The best bet is to look for WPF samples online for specific concepts like this and then apply them in NinjaTrader.

    Because NinjaTrader is a WPF application that already has key events on the objects you are using, the PreviewKey events are generally needed to intercept key events. This is also not NinjaTrader specific but is standard with WPF design.


    I look forward to being of further assistance.
    JesseNinjaTrader Customer Service

    Comment


      #3
      Thank you very much. Let's see what I can do

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by Stanfillirenfro, Today, 07:23 AM
      1 response
      3 views
      0 likes
      Last Post NinjaTrader_Gaby  
      Started by cmtjoancolmenero, Yesterday, 03:58 PM
      2 responses
      20 views
      0 likes
      Last Post cmtjoancolmenero  
      Started by olisav57, Yesterday, 07:39 PM
      1 response
      9 views
      0 likes
      Last Post NinjaTrader_ChelseaB  
      Started by cocoescala, 10-12-2018, 11:02 PM
      7 responses
      944 views
      0 likes
      Last Post Jquiroz1975  
      Started by oviejo, Today, 12:28 AM
      1 response
      12 views
      0 likes
      Last Post NinjaTrader_Gaby  
      Working...
      X