[RhinoCommon] Options pages with child pages - dialog gets stuck

We have some options pages that have child pages, and I notice that once a child page is selected, navigation gets stuck and no other pages can be selected. A minimal reproduction of this error is found here (adapted from the Samples from GitHub). The SampleCsOptionsParentPage is registered in the OnLoad method of the plugin.

@dale
How do I properly register a child options page? In Rhino-5 the method below works.

internal class SampleCsOptionsParentPage : OptionsDialogPage
{
  private UserControl m_control;

  public SampleCsOptionsParentPage()
    : base("Sample-Parent")
  {
    Children.Add(new SampleCsOptionsChildPage());
  }

  public override object PageControl
  {
    get { return m_control ?? (m_control = new UserControl()); }
  }

  public override bool OnApply()
  {
    RhinoApp.WriteLine("SampleCsOptionsParentPage.OnApply");
    return true;
  }

  public override void OnCancel()
  {
    RhinoApp.WriteLine("SampleCsOptionsParentPage.OnCancel");
  }
}

internal class SampleCsOptionsChildPage : StackedDialogPage
{
  private SampleCsOptionsUserControl m_control;

  public SampleCsOptionsChildPage()
    : base("Sample-Child")
  {
  }

  public override object PageControl
  {
    get { return m_control ?? (m_control = new SampleCsOptionsUserControl()); }
  }

  public override bool OnApply()
  {
    RhinoApp.WriteLine("SampleCsOptionsChildPage.OnApply");
    return true;
  }

  public override void OnCancel()
  {
    RhinoApp.WriteLine("SampleCsOptionsChildPage.OnCancel");
  }
}

Is this Rhino 6 or Rhino 5? What do you mean when you say "The SampleCsOptionsParentPage is registered in the OnLoad", pages should be added in the
protected override void DocumentPropertiesDialogPages(RhinoDoc doc, List<OptionsDialogPage> pages)
or
protected override void OptionsDialogPages(List<OptionsDialogPage> pages)
plug-in class.

I have included simple V5 and V6 solutions that add options and document properties pages which contain child pages.

OptionsPageWithChild.zip (375.3 KB)

1 Like

pages should be added in the
protected override void DocumentPropertiesDialogPages(RhinoDoc doc, List<OptionsDialogPage> pages)

Of course, and that is also what our plug-in is doing, my mistake in writing it incorrectly.

@JohnM Thanks for your sample code, I have traced the error to the fact that our child page inherits from StackedDialogPage instead of from OptionsDialogPage; it was probably done this way because the Children collection is of type List<StackedDialogPage>.

When I change it to the correct inheritance, the problem goes away. Thanks for you quick reply, it helped a lot :slight_smile: