Bug in eto Scrollable

Please copy below code to some class file in Rhino C# Plugin and run “ScrollableBug” command few times. When we check for scroll position then srollable forces dialog to become very big.

Tested on Rhino 7 SR28 for Windows.

using Eto.Forms;
using Eto.Drawing;
using Rhino;
using Rhino.Commands;
using Rhino.UI;
using Command = Rhino.Commands.Command;

namespace Test
{
    //Run this command few times and play with scrollbar. When dialog checks for scrollable position its size grows unintentionally
    public class ScrollableBugDialogCommand : Command
    {
        public static ScrollableBugDialogCommand Instance { get; private set; }

        public override string EnglishName { get; } = "ScrollableBug";

        public ScrollableBugDialogCommand()
        {
            Instance = this;
        }

        protected override Result RunCommand(RhinoDoc doc, RunMode mode)
        {
            new ScrollabeBugDialog().ShowModal(RhinoEtoApp.MainWindow);

            return Result.Success;
        }
    }   

    public class ScrollabeBugDialog : Dialog
    {
        private static bool checkScrollPosition = false;
        private Scrollable dialogScrollable;

        public ScrollabeBugDialog()
        {
            dialogScrollable = new Scrollable()
            {
                Height = 200,
                Width = 200,
                Content = new Label
                {
                    Text = "Some Label",
                    Font = new Font(SystemFont.Default, 20),
                    Size = new Size(300, 300)
                },
            };

            var content = new DynamicLayout();
            content.AddRow(null, dialogScrollable, null);
            content.AddRow(null, new Button() 
            {
                Text = "Some Button",
                Font = new Font(SystemFont.Default, 20),
                Size = new Size(300, 300)
            });

            Content = content;

            if (checkScrollPosition) dialogScrollable.Scroll += (sender, e) => CheckScrollPosition();
            else RhinoApp.WriteLine("Not checking scroll position.");

            checkScrollPosition = !checkScrollPosition;
        }

        private void CheckScrollPosition()
        {
            RhinoApp.WriteLine("Scroll position is :" + dialogScrollable.ScrollPosition.ToString());
        }
    }
}

Dialog scrollable in Rhino 7 SR28 for macOS works fine with no problems, so this issue is Windows related.

Not checking scroll position:

Checking scroll position:

Hello @dale, are you able to comment if it is possible to do something with this issue?

Hi @mlukasz87,

I prefer using a TableLayout.

TestLukaszCommand.cs (1.9 KB)

– Dale

2 Likes

Thank you @dale. Issue was present when Scrollable was field of Class. After changing it to local variable problem is gone.

However I am still trying to figure out how to apply above to xeto file. I am afraid that all xeto dialog controls are imported as fields or properties internally.