• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Escape Key recognition

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

    Escape Key recognition

    Hello,

    I am attempting to use the Escape Key to abort a drawing action if required using

    private void OnKeyDownHandler(object sender, KeyEventArgs e)
    {

    if (e.Key==Key.Escape)
    {
    Print("Escape key pressed");
    }
    }

    however this is not being recognized. I have seen on some general C# forums that Escape Key recognition within WPF can be problematic.

    Can someone please offer any suggestions on if/how this can be done.

    Thank you.

    #2
    Hello,

    Thank you for the question.

    I am unsure by the sample on what object you are using for the key event, but I have seen for Buttons using the MouseDown event this does not bubble the event in a chart, so instead the PreviewMouseDown was used.

    Can you try using the PreviewKeyDown event instead if available for the object? This may allow you to get the correct keys if you are able to use this event.

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

    Comment


      #3
      Hi Jesse,

      Thank you for the reply and suggestion.

      After much trial and error, it seems that the Escape key is not available to NinjaScript (caveat - it should be noted I have limited coding skills.......)

      Using the code below I found that the keys not used by NT will print, however it seems that any key used by NT is locked out and not accessible via PreviewKeyDown. This is different to NT7 where the Escape key was available programatically.

      public void PreviewKeyDown(object sender, KeyEventArgs e)
      {

      Print(e.Key.ToString());

      }

      and in State == State.Historical

      ChartPanel.PreviewKeyDown += PreviewKeyDown;

      Any suggestions for a work around here so I can use the Escape key?

      Thanks

      Comment


        #4
        Originally posted by rt-trader View Post
        Any suggestions for a work around here so I can use the Escape key? Thanks
        Try this instead..


        Attached Files
        -=Edge=-
        NinjaTrader Ecosystem Vendor - High Tech Trading Analysis

        Comment


          #5
          Perfect - thank you very much Edge

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by Jakub, Yesterday, 11:52 AM
          1 response
          16 views
          0 likes
          Last Post NinjaTrader_PatrickG  
          Started by dltharpe, Yesterday, 09:17 AM
          1 response
          10 views
          0 likes
          Last Post NinjaTrader_PatrickG  
          Started by Johnny Santiago, 10-11-2019, 08:21 AM
          7 responses
          109 views
          0 likes
          Last Post FMtrader  
          Started by HiddenPhilosopher, Today, 04:37 AM
          0 responses
          7 views
          0 likes
          Last Post HiddenPhilosopher  
          Started by Gerik, Today, 04:09 AM
          0 responses
          3 views
          0 likes
          Last Post Gerik
          by Gerik
           
          Working...
          X