CT 4.2 Chart Freeze Adding a Canvas

ClickAlgo's avatar

ClickAlgo since: 05 Feb 2015;

  27 May 2022, 08:53
CT 4.2 Chart Freeze Adding a Canvas

Hi, 

I have noticed a break in functionality from CT 4.1, when you add a canvas to a chart for an indicator it freezes the chart and you cannot move it, I have added some code as an example.

namespace cAlgo
{
    [Indicator(AccessRights = AccessRights.None)]
    public class CanvasTest : Indicator
    {
        [Parameter(DefaultValue = "Hello world!")]
        public string Message { get; set; }

        [Output("Main")]
        public IndicatorDataSeries Result { get; set; }

        protected override void Initialize()
        {
             var blueRectangle = new Rectangle()
            {
                Width = 80,
                Height = 60,
                FillColor = Color.Blue,
                Left = 10,
                Top = 10
            };

            Canvas canvas = new();
            
            canvas.AddChild(blueRectangle);
            
            Chart.AddControl(canvas);
        }

        public override void Calculate(int index)
        {
            // Calculate value at specified index
            // Result[index] = 
        }
    }
}
~ Contact us for all your cBot & Indicator development ~
amusleh's avatar

amusleh since: 01 Mar 2021;

  27 May 2022, 09:05

Hi,

Thanks for reporting, we were able to reproduce it and it will be fixed on future releases.

Community Developer | Spotware | Telegram: @algodeveloper
Jiri's avatar

Jiri since: 31 Aug 2015;

  27 May 2022, 10:14

I have noticed this as well, it's acting as if the canvas is having transparent background which makes it capture mouse events. You can set IsHitTestVisible to false to fix that but that will affect all the child items which might not be desirable. Setting the BackgroundColor to null does not help.

Co-Founder & CTO at PoshTrader Ltd with +8 years of trading experience. Providing programming services and a marketplace where you can buy and sell addons for trading platforms - www.poshtrader.com