• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

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.
      Patrick H.NinjaTrader Customer Service

      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
        Patrick H.NinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Bionian, Today, 10:10 AM
        2 responses
        14 views
        0 likes
        Last Post NinjaTrader_ShawnB  
        Started by D Trader, Today, 01:41 PM
        0 responses
        7 views
        0 likes
        Last Post D Trader  
        Started by rexmie888, Today, 04:00 AM
        1 response
        9 views
        0 likes
        Last Post NinjaTrader_ShawnB  
        Started by terminatorT1000, Today, 01:23 AM
        1 response
        11 views
        0 likes
        Last Post NinjaTrader_ShawnB  
        Started by Tradarr, Today, 12:25 PM
        0 responses
        7 views
        0 likes
        Last Post Tradarr
        by Tradarr
         
        Working...
        X