Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

MouseLeftButtonDown for TextBox()

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

    MouseLeftButtonDown for TextBox()

    I have a half-transparent text box that on top of a few candle bars, what I am trying to do
    is getting mouse x,y location (price levels and date/time) when I click inside the text box
    (because those candle bars are still visible under the half transparent text box)

    Wonder if TextBox() mouse events would achieve this? Sorry, I am really new to C#

    I managed to handle keyboard events inside the text box and get the correct key values,
    by following NinjaTrader_Matthew's code:
    https://forum.ninjatrader.com/forum/historical-beta-archive/version-8-beta/77882-disabling-keydown-event-in-chart?_gl=1*meh2sa*_gcl_au*MjA5ODk4ODUuMTcyOTM5MDY 2NA..#post685973

    I am trying to do the same thing for mouse events, but it didn't work.
    textBox.MouseLeftButtonDown += TextBox_MouseLeftButtonDown;

    The error message:
    The name "TextBox_MouseLeftButtonDown" does not exist in the current context

    I hope support team could give me some directions or sample codes.

    Thanks so much!
    Last edited by warpinator; 11-03-2024, 12:36 PM.

    #2
    Hello warpinator,

    I'm not sure what you're trying to achieve with this description. Are you looking to get prices for bars specifically located behind the text box? If so that wouldn ot be possible, the textbox is a WPF control which will be on top of the bars and prevent your mouse from interacting with the chart behind it.

    Comment


      #3
      Hi Jesse,

      Thanks so much for your reply, is it possible to get X, Y coordinates when I click inside the Text Box?

      I managed to get X, Y coordinates when I hover the mouse over Text Box, by following this example:


      Comment


        #4
        Hello warpinator,

        Not that I am aware of, when you click inside the control that gives focus to the text box. That is not a chart or area which has X/Y coordinates associated with the chart behind it, that is a WPF text box for text entry. You could move the textbox out of the chart to the toolbar or a different area so it's not in the way of where you are trying to click.

        Comment


          #5
          Hi Jesse,

          Thanks for your reply, I will move the Text Box away from the area I need to click.

          Just one last question, since the Text Box is not at fix location (based on price actions), is it possible
          I would be able to detect that the mouse click is inside Text Box? (a boolean value would be perfect)
          so I can give myself an alert, I would forget to move the Text Box away at heat of moment when market
          is crazy.

          Thanks so much Jesse !

          Comment


            #6
            Hi Jesse,

            Another thought regarding my last reply (post #5):

            If there's a way to detect whether the cursor is entering the
            Text Box or leaving, that will help a lot too.

            Thanks !

            Comment


              #7
              Hello warpinator,

              These items are not specific to NinjaScript but instead for WPF controls. You can find samples of WPF topics by searching online. For mouse events on controls, you can use the preview mouse events like PreviewMouseUp or PreviewMouseDown.

              https://learn.microsoft.com/en-us/do...edown?view=win dowsdesktop-8.0

              I would be unsure if there is a way to detect the mouse entering or leaving, but you can use the PreviewMouseMove event to see movement over the control.

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by Geovanny Suaza, 02-11-2026, 06:32 PM
              0 responses
              558 views
              0 likes
              Last Post Geovanny Suaza  
              Started by Geovanny Suaza, 02-11-2026, 05:51 PM
              0 responses
              324 views
              1 like
              Last Post Geovanny Suaza  
              Started by Mindset, 02-09-2026, 11:44 AM
              0 responses
              101 views
              0 likes
              Last Post Mindset
              by Mindset
               
              Started by Geovanny Suaza, 02-02-2026, 12:30 PM
              0 responses
              545 views
              1 like
              Last Post Geovanny Suaza  
              Started by RFrosty, 01-28-2026, 06:49 PM
              0 responses
              547 views
              1 like
              Last Post RFrosty
              by RFrosty
               
              Working...
              X