Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

OnMouseClick Event to a drawing Object

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

    OnMouseClick Event to a drawing Object

    Hi,

    How do we identify an event if I click on an object. Example if I click on a rectangle, I will do some event to that rectangle, how can I do that?

    Thanks.

    #2
    Hello kezyclaire,

    Thank you for your post.

    Drawing objects are intended to be moved when they are clicked/selected, so trying to add a mouse click event to a drawing tool could get tricky and is not advised. It may be easier and more efficient to add a button to the chart instead and add a .Click handler event to the button. This has been discussed in the following thread, where a user did create a solution for when the drawing object is clicked:
    Hi, I do have a way to do this, but I was wondering if there a better, simpler way to do this? Basically I wish to turn a FixedText into a switch button. To do that I need mouseclick event, then a way to check if the cursor has clicked on the drawing object. alertStatusSwitch flips between true/false The magic happens here:


    If you would like to work with a button added to the chart instead of clicking a drawing object, the button could be added in a way that the sample script linked in that post does it. You could also consider the SampleWPFModifications script for adding buttons and using a click event handler. There are sampleButton snippets on the "Other Uses for an AddOn" page as well:Please let us know if we may be of further assistance.

    Comment


      #3
      Hi Emily,

      Ok, so how do I get the object that I clicked on and I will start from there. Since I dynamically created all the objects, I need to get the Tag Name of the object so I can manipulate the object.

      Thanks.

      Comment


        #4
        Hello kezyclaire,

        Thank you for your reply.

        Detecting a mouse click on a drawing object would require custom C# logic that goes beyond the level of NinjaScript-specific support that our team offers. You could review the unsupported snippet from the forum post I previously linked to get an idea of how that user created a cursor object tied to the TextFixed object they draw in the script and see if this approach would suit your needs. You could also consider looping through the draw objects collection as shown in the snippet on this page to see if this works for your desired behavior:


        Otherwise, a button might be more suitable and the resources I provided offer some ideas on how a button could be added to that chart and associated with a click event.

        Please feel free to reach out with any additional questions or concerns.

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Geovanny Suaza, 02-11-2026, 06:32 PM
        0 responses
        647 views
        0 likes
        Last Post Geovanny Suaza  
        Started by Geovanny Suaza, 02-11-2026, 05:51 PM
        0 responses
        368 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
        571 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