am I correct to say there is no way to produce a combo box when using AddAutomaticUserInterfaceSection?
seems to imply some extension of Rhino.Render.Fields, like an Add overload taking an enum type to build the combobox, perhaps optionally looking for display name & description attributes to use
The below code adds a combobox called combo1 with a default value 1 and a title “Text combo box”
Fields.Add("combo1", 1, "Text combo box");
Then one has to override the GetChildSlotParameter function. One has to return the value 3 in the “ui-hint”. This specifies that the control is a combobox. The current enum is internal, but this will work.
public override object GetChildSlotParameter(string childSlotName, string parameterName)
{
if (childSlotName == "combo1")
{
if (parameterName == "ui-hint")
{
return 3; // Combo
}
if (parameterName == "control-set-enable")
{
return true;
}
if (parameterName == "combo-box-contents")
{
return "Value1;Value2;Value3";
}
}
return base.GetChildSlotParameter(parameterName, childSlotName);
}
it seems all is not working properly with this; the UI gets created, and operates, but it is only the first combo-box change that sticks, until I de-select the environment, and then select it again
here is a screen recording using 8.3.24009.15001 (my rhino has not yet asked to upgrade), raytraced viewport (which makes it clearer what is going on, by either restarting when a parameter changes, or not), where when I set a double field I see the update occur each time, but where when I change the combo box, only the first change after de-selecting/re-selecting the environment actually registers
the full code for this test environment is this:
using Rhino.Render;
using System;
using System.Drawing;
using System.Runtime.InteropServices;
namespace test_plugin
{
[Guid("6A404915-005D-4D27-B779-A881DFD162EB")]
public class TestEnvironment : RenderEnvironment
{
public override string TypeName => "TestEnvironment";
public override string TypeDescription => "TestEnvironment";
public TestEnvironment()
{
Fields.Add("testDouble", 1.234567, "Test Double");
Fields.Add("testColor", Color.Gray, "Test Color");
Fields.Add("combo1", 1, "Text combo box");
}
protected override void OnAddUserInterfaceSections()
{
AddAutomaticUserInterfaceSection("Parameters", 0);
}
public override object GetChildSlotParameter(string childSlotName, string parameterName)
{
if (childSlotName == "combo1")
{
if (parameterName == "ui-hint")
return 3; // Combo
if (parameterName == "control-set-enable")
return true;
if (parameterName == "combo-box-contents")
return "Value1;Value2;Value3";
}
return base.GetChildSlotParameter(parameterName, childSlotName);
}
}
}