• 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

Detecting key press event in selected DrawingTool

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

    Detecting key press event in selected DrawingTool

    Hi,
    Is there any way to detect that the user pressed a key when a custom DrawingTool on a chart was selected? I would like to detect it within the custom DrawingTool.

    Thank you.

    #2
    Hello CycleArt,

    Thanks for your inquiry.

    Within the GetCursor() method, you could check the DrawingState of the Drawing object to see if it is selected.

    As a rough example, you may consider the following:
    Code:
    private bool selected = false;
    private bool doOnce = true;
    
    public override Cursor GetCursor(ChartControl chartControl, ChartPanel chartPanel, ChartScale chartScale, Point point)
    {
    	if (DrawingState == DrawingState.Normal)
    		selected = true;
    	else
    	{
    		selected  = false;
    		doOnce = true;
    	}
    	
    	if(selected && doOnce)
    	{			
    		Print(DrawingState.ToString());
    		doOnce = false;
    	}
    }
    Detecting button presses can be done through C# by using System.Windows.Input.Keyboard.IsKeyDown. This concept is external to NinjaScript and would be referenced on the MSDN documentation page for usage.

    System.Windows.Input.Keyboard.IsKeyDown - https://msdn.microsoft.com/en-us/lib...v=vs.110).aspx

    Publicly available documentation on GetCursor() can be found here - https://ninjatrader.com/support/help.../getcursor.htm

    Please let us know if you have any additional questions.
    JimNinjaTrader Customer Service

    Comment


      #3
      Thank you, Jim!

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by rickyblah12, Yesterday, 08:17 PM
      0 responses
      6 views
      0 likes
      Last Post rickyblah12  
      Started by mrlucky1x, Yesterday, 08:07 PM
      0 responses
      2 views
      0 likes
      Last Post mrlucky1x  
      Started by uday12, Yesterday, 07:21 PM
      0 responses
      4 views
      0 likes
      Last Post uday12
      by uday12
       
      Started by voltlon, Yesterday, 05:18 PM
      0 responses
      8 views
      0 likes
      Last Post voltlon
      by voltlon
       
      Started by Bobisam, Yesterday, 04:57 PM
      0 responses
      9 views
      0 likes
      Last Post Bobisam
      by Bobisam
       
      Working...
      X