namespace MenuInput
{
public class MenuInputComponent : GH_Component
{
private double _number;
public MenuInputComponent() : base("MenuInput", "Nickname",
"Description", "Category", "Subcategory")
{ }
protected override void RegisterInputParams(GH_InputParamManager pManager) { }
protected override void RegisterOutputParams(GH_OutputParamManager pManager)
{
pManager.AddNumberParameter("O", "O", "O", GH_ParamAccess.item);
}
protected override void SolveInstance(IGH_DataAccess DA)
{
DA.SetData(0, _number);
}
public override void AppendAdditionalMenuItems(ToolStripDropDown menu)
{
var setInt = Menu_AppendItem(menu, "Set Number");
Menu_AppendTextItem(setInt.DropDown, _number.ToString(CultureInfo.InvariantCulture), null, TextChanged, true);
}
private void TextChanged(GH_MenuTextBox sender, string newText)
{
_number = Convert.ToDouble(newText);
ExpireSolution(true);
}
protected override System.Drawing.Bitmap Icon => null;
public override Guid ComponentGuid => new Guid("d2bc99d5-36b1-4139-b42d-f21ac50d3a90");
}
}
MenuInput.zip (22.5 KB) MenuInput.gha (6 KB)