Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Can keyboard recognition on a chart be turned off from code?

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

    Can keyboard recognition on a chart be turned off from code?

    I have a UserControl which I add to a chart. The control has text boxes. When I click in the textbox and type a character, it invokes the same symbol selection dialog/window that would happen if I was simply looking at a plain chart and typed a character.

    Is there a way to turn off, via ninjascript, this keyboard trigger of the symbol changer?
    Also, is there a way to turn it back on (when user leaves the textbox)?

    Thanks,
    Gary

    #2
    Hello,

    Thank you for the question,

    After review with product management,
    Keyboard events work in a 'bubble down' fashion where subscribed listeners get events and pass it down the key event to the next subscriber (or eat and don't pass it down it if programmed to do so).

    The problem in your case would be that a chartcontrols overlay instrument selector is higher up in the chain then you would have access to.

    I will submit this as a feature request to be looked further into.


    I look forward to being of further assistance.
    Last edited by NinjaTrader_Jesse; 02-18-2016, 08:40 AM.
    JesseNinjaTrader Customer Service

    Comment


      #3
      I would like to hear any 'unsupported' solutions as well.

      Gary

      Comment


        #4
        Originally posted by GaryAlbers View Post
        I would like to hear any 'unsupported' solutions as well.

        Gary
        Has your UserControl subscribed to the Keyboard event handler?

        Comment


          #5
          No, it only handles events from buttons on the UserControl.

          Gary

          Comment


            #6
            Originally posted by GaryAlbers View Post
            No, it only handles events from buttons on the UserControl.

            Gary
            Somewhere in your code you must subscribe to the keyboard events. As your handler will almost certainly be loaded last, you get to handle the key events first. Here is a quick and dirty example. You will have to add some error-handling, and probably subscribe to other key events. This is for key down only.
            Code:
            protected override void OnStartUp()
            {    
                if (ChartControl != null) ChartControl.ChartPanel.KeyDown += MyEventHandlerMethod;
            }
            
            protected override void OnTermination()
            {
                if (ChartControl != null) ChartControl.ChartPanel.KeyDown -= MyEventHandlerMethod;
            }    
            
            public void MyEventHandlerMethod(object sender, KeyEventArgs e)
            {
                Print("Tickety boo, I got the key press!");
            }
            You will also have to write the glue for the UserControl.

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by AttiM, 02-14-2024, 05:20 PM
            12 responses
            212 views
            0 likes
            Last Post DrakeiJosh  
            Started by cre8able, 02-11-2023, 05:43 PM
            3 responses
            237 views
            0 likes
            Last Post rhubear
            by rhubear
             
            Started by frslvr, 04-11-2024, 07:26 AM
            8 responses
            116 views
            1 like
            Last Post NinjaTrader_BrandonH  
            Started by stafe, 04-15-2024, 08:34 PM
            10 responses
            47 views
            0 likes
            Last Post stafe
            by stafe
             
            Started by rocketman7, Today, 09:41 AM
            3 responses
            11 views
            0 likes
            Last Post NinjaTrader_Jesse  
            Working...
            X