Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Problem clic on panel

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

    Problem clic on panel


    Hello, I designed an indicator that when clicking on the panel draws a box with information in the same onrender panel, the click basically receives the bar and with that bar I get the information I want, there are people that it doesn't work well for them, so I can accept them that click and to be able to reference the bar they need to raise the indicator panel higher and at the bottom then if it works normally​


    I don't know what could be happening for this to happen, it works correctly for most of us.

    #2
    Hello RubenCazorla,

    From the given details I would not be sure what specifically may be happening. Its possible that relates to the windows DPI setting, you may want to check if they have a different than normal DPI setting. Other than that you would likely need to debug the script to see what specific logic is being affected so we have a better idea of what the problem could be related to.

    Comment


      #3
      Click image for larger version

Name:	image.png
Views:	78
Size:	97.2 KB
ID:	1321222

      In this image you can see the problem, both clicks are inside the panel, but one of them calculates it as if it were outside

      private void OnMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
      {
      // Obtener la fuente de presentación del ChartControl
      var source = PresentationSource.FromVisual(ChartControl);

      // Obtener la posición del ratón
      Point mousePosition = e.GetPosition(ChartControl);

      // Ajustar las coordenadas del ratón según el DPI
      double dpiX = 1.0, dpiY = 1.0;
      if (source != null && source.CompositionTarget != null)
      {
      dpiX = source.CompositionTarget.TransformToDevice.M11;
      dpiY = source.CompositionTarget.TransformToDevice.M22;
      }

      int mouseX = (int)Math.Round(mousePosition.X * dpiX);
      int mouseY = (int)Math.Round(mousePosition.Y * dpiY);

      // Calcular los bordes del panel
      double panelLeft = chartPanel.X * dpiX;
      double panelTop = chartPanel.Y * dpiY;
      double panelRight = (panelLeft + chartPanel.W) * dpiX;
      double panelBottom = (panelTop + chartPanel.H) * dpiY;

      // Verificar si la posición ajustada del ratón está dentro del panel
      if (mouseX >= panelLeft && mouseX <= panelRight && mouseY >= panelTop && mouseY <= panelBottom)
      {
      mouseDown = true;
      }
      }



      private void OnMouseLeftButtonUp(object sender, MouseButtonEventArgs e)
      {
      Point mousePosition = e.GetPosition(ChartControl);

      for (int i = 0; i < ChartControl.ChartPanels.Count; i++)
      {
      var panel = ChartControl.ChartPanels[i];
      if (panel == chartPanel)
      {
      double panelLeft = chartPanel.X;
      double panelTop = chartPanel.Y;
      double panelRight = panelLeft + chartPanel.W;
      double panelBottom = panelTop + chartPanel.H;
      Print("mouseDown " + mouseDown);
      Print("mousePosition " + mousePosition);
      Print("panelLeft " + panelLeft);
      Print("panelRight " + panelRight);
      Print("panelTop " + panelTop);
      Print("panelBottom " + panelBottom);
      break;
      }
      }​.....
      ​Am I leaving something out? any reference using to dpi?
      Attached Files

      Comment


        #4
        Hi RubenCazorla,

        ninZa.co has an indicator called "Smart Data Box" that can do this.



        For more details, don't hesitate to get in touch with the support team: https://ninza.co/contact

        Regards,
        William
        ninZa
        NinjaTrader Ecosystem Vendor - ninZa.co

        Comment


          #5
          Originally posted by ninZa View Post
          Hi RubenCazorla,

          ninZa.co has an indicator called "Smart Data Box" that can do this.



          For more details, don't hesitate to get in touch with the support team: https://ninza.co/contact

          Regards,
          William
          I'm sorry but it's not what I'm looking for, nor do I know how this can help me with the problem I'm referring to.

          Comment


            #6
            Hello RubenCazorla,

            You used different code in both of the events, do you still see a problem is you instead use the same code in both methods?

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by Geovanny Suaza, 02-11-2026, 06:32 PM
            0 responses
            668 views
            0 likes
            Last Post Geovanny Suaza  
            Started by Geovanny Suaza, 02-11-2026, 05:51 PM
            0 responses
            377 views
            1 like
            Last Post Geovanny Suaza  
            Started by Mindset, 02-09-2026, 11:44 AM
            0 responses
            110 views
            0 likes
            Last Post Mindset
            by Mindset
             
            Started by Geovanny Suaza, 02-02-2026, 12:30 PM
            0 responses
            575 views
            1 like
            Last Post Geovanny Suaza  
            Started by RFrosty, 01-28-2026, 06:49 PM
            0 responses
            580 views
            1 like
            Last Post RFrosty
            by RFrosty
             
            Working...
            X