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 AaronKoRn, Today, 09:49 PM
      0 responses
      11 views
      0 likes
      Last Post AaronKoRn  
      Started by carnitron, Today, 08:42 PM
      0 responses
      10 views
      0 likes
      Last Post carnitron  
      Started by strategist007, Today, 07:51 PM
      0 responses
      11 views
      0 likes
      Last Post strategist007  
      Started by StockTrader88, 03-06-2021, 08:58 AM
      44 responses
      3,980 views
      3 likes
      Last Post jhudas88  
      Started by rbeckmann05, Today, 06:48 PM
      0 responses
      9 views
      0 likes
      Last Post rbeckmann05  
      Working...
      X