Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

selecting a draw object without clicking an anchor

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

    selecting a draw object without clicking an anchor

    I'm currently looking for a way to select a draw object via code

    I can set MyDrawObject.IsSelected to true in code but it seems to instantly get switched back to false. The only places in the draw object code I see IsSelected get set to false seem to have no relevance on this when I code my own draw object.

    Example simple script I'm using as a test

    Code:
    private Rectangle zone = null;
    
            protected override void OnBarUpdate()
    		{
                //Add your custom indicator logic here.
    
                if (State < State.Realtime) return;
    
    
                if (zone == null)
                {
                    foreach (IDrawingTool draw in DrawObjects)
                    {
                        if (draw is DrawingTools.Rectangle
                            && zone == null)
                        {
                            zone = draw as Rectangle;
    
                            zone.IsSelected = true;
                        }
                    }
                }
    
                if (zone != null)
                {
                    Print("zone.IsSelected: " + zone.IsSelected);
                }
            }
    using this code I see on the first OBU event it will set the Rectangle.IsSelected to true but instantly changes to false without the object ever showing its anchors


    If this is not possible I was thinking I could customize a draw object such that it would select itself when the "fill area" is clicked, however it seems the draw objects "mouse down" event only gets called when the outline is clicked.

    #2
    Hi HandsFreeTrader,

    I was able to confirm the behavior.

    I also tried setting .IsLocked to false and DrawingState to DrawingState.Editing before setting .lsSelected to true.

    I'll ask with development and find out why this is being set back to false.
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Hello HandsFreeTrader,

      Can you provide a specific use case scenario for selecting an object via code? A basic example is fine, we just need to be able to provide a start to finish scenario to development.

      We look forward to your response.

      Comment


        #4
        This specific case was resolved by using the code below in OnRender rather than IsSelected:
        Code:
        protected override void OnRender(ChartControl chartControl, ChartScale chartScale)
        {
            if (IsInHitTest)
                return;
        }
        For information on IsInHitTest please visit the following link: http://ninjatrader.com/support/helpG...sinhittest.htm

        Comment

        Latest Posts

        Collapse

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