Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Drawing Tool Not Capturing LeftCtrl + LeftMouseDown

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

    Drawing Tool Not Capturing LeftCtrl + LeftMouseDown

    Hello,
    I want to add the code to a Drawing Tool script that will catch LeftCtrl key and LeftMouseButton combination. I added the following code to an indicator. It works - LeftMouseButton down and LeftCtrl key pressed sends a message to the output window.
    Code:
                else if (State == State.DataLoaded)
                {
                    if (ChartPanel != null)
                    {
                        ChartPanel.MouseLeftButtonDown += ChartPanel_MouseLeftButtonDown;
                    }
                }
                else if (State == State.Terminated)
                {
                   if (ChartPanel != null)
                    {
                        ChartPanel.MouseLeftButtonDown -= ChartPanel_MouseLeftButtonDown;
                    }
                }
    
    
    ​        private void ChartPanel_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
            {
                if (Keyboard.IsKeyDown(Key.LeftCtrl))
                {
                    Print($"LeftControlDown.ChartPanel_MouseLeftButtonDown ");
                }
            }
    ​
    I then added the same code with 1 modification to OnStateChange() section State.Active versus State.DataLoaded
    Code:
                else if (State == State.Active)
                {
                    if (ChartPanel != null)
                    {
                        ChartPanel.MouseLeftButtonDown += ChartPanel_MouseLeftButtonDown;
                    }
                }
                else if (State == State.Terminated)
                {
                    // release any device resources
                    if (ChartPanel != null)
                    {
                        ChartPanel.MouseLeftButtonDown -= ChartPanel_MouseLeftButtonDown;
                    }
                    Dispose();
                }
              
    ​
            private void ChartPanel_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
            {
                if (Keyboard.IsKeyDown(Key.LeftCtrl))
                {
                    Print($"LeftControlDown.ChartPanel_MouseLeftButtonDown ");
                }
            }​
    The drawiing tool version compiles but does nothing when LeftCtrl and LeftMouseDown
    buttons are pushed. Does the script need to be different for the drawing tool or placed in a different place?

    Thanks in advance for any suggestions.​
    Last edited by ramckay; 08-28-2024, 04:22 AM.

    #2
    Hello ramckay,

    That is because the platform is creating a custom event for the drawing tool mouse events based on the interactions in the chart and how selection works in the chart. This is not quite the same as the WPF mouse down handler that you have shown. The only events that will be provided to the drawing tool would be the base mouse actions involved with manipulating the tools anchors. In this case I wouldnt have a specific solution that I could provide as the internal logic that provides the events to the drawing object is not something which can be modified in NinjaScript.

    Comment


      #3
      Hi Jesse,
      You say only 'base mouse actions'. I should be able to work with that. What are the 'base mouse actions'?
      Thanks

      Comment


        #4
        Hello ramckay,

        That would be the name of each override, for example mouse down is only called when the mouse is down. Drawing objects mouse events are limited to the actions which they are intended to do in the chart to configure the anchors.

        Comment


          #5
          Hi Jesse,
          I checked the DrawingTool I'm working with. It has MouseDown, MouseMove, and MouseUp. I'll run the script and let you know.
          Thanks

          Comment


            #6
            Hi Jesse,
            I added this code to the OnMouseDown() handler in the DrawingTool and it works like a champ.
            Code:
                        if (Keyboard.IsKeyDown(Key.LeftCtrl))
                        {
                            Print($"LeftControlDown.ChartPanel_MouseLeftButtonDown ");
                        }​
            Thanks for the heads up.

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by Geovanny Suaza, 02-11-2026, 06:32 PM
            0 responses
            648 views
            0 likes
            Last Post Geovanny Suaza  
            Started by Geovanny Suaza, 02-11-2026, 05:51 PM
            0 responses
            369 views
            1 like
            Last Post Geovanny Suaza  
            Started by Mindset, 02-09-2026, 11:44 AM
            0 responses
            108 views
            0 likes
            Last Post Mindset
            by Mindset
             
            Started by Geovanny Suaza, 02-02-2026, 12:30 PM
            0 responses
            572 views
            1 like
            Last Post Geovanny Suaza  
            Started by RFrosty, 01-28-2026, 06:49 PM
            0 responses
            573 views
            1 like
            Last Post RFrosty
            by RFrosty
             
            Working...
            X