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 FrancisMorro, Today, 03:24 AM
      0 responses
      1 view
      0 likes
      Last Post FrancisMorro  
      Started by Segwin, 05-07-2018, 02:15 PM
      10 responses
      1,770 views
      0 likes
      Last Post Leafcutter  
      Started by Rapine Heihei, 04-23-2024, 07:51 PM
      2 responses
      31 views
      0 likes
      Last Post Max238
      by Max238
       
      Started by Shansen, 08-30-2019, 10:18 PM
      24 responses
      944 views
      0 likes
      Last Post spwizard  
      Started by Max238, Today, 01:28 AM
      0 responses
      11 views
      0 likes
      Last Post Max238
      by Max238
       
      Working...
      X