algorithmic modeling for Rhino
Hi Guys,
After several unsuccessful attempts based on this great thread, I still have not managed to place the right constructor in the class derived from the GH_ComponentAttributes. What should I use there, for what reason and how could I have guessed this information using the GH SDK?
public class SettingsComponentAttributes : GH_ComponentAttributes
{
//Which constructor?
public override GH_ObjectResponse RespondToMouseDoubleClick(GH_Canvas sender, GH_CanvasMouseEvent e)
{
((SettingsComponent)Owner).ShowSettingsGui();
return GH_ObjectResponse.Handled;
}
}
Visual Studio Express suggests the following constructor with a TO DO but I am not sure what member initialization means in that context:
private SettingsComponent settingsComponent;
public SettingsComponentAttributes(SettingsComponent settingsComponent)
{
// TODO: Complete member initialization
this.settingsComponent = settingsComponent;
}
Many many thanks,
Arthur
Tags:
GH_ComponentAttributes only has a single constructor, so you really don't have any choice in the matter. Your constructor must call this one and only base class constructor. Since the base class constructor looks like this:
public GH_ComponentAttributes(IGH_Component component){...}
you have to get an IGH_Component from somewhere too. Easiest would be to simply duplicate the constructor signature:
public class SettingsComponentAttributes : GH_ComponentAttributes
{
public SettingsComponentAttributes(IGH_Component component) : base(component) {...}
}
--
David Rutten
david@mcneel.com
Poprad, Slovakia
Thank you very much David, it is working now :)
public class SettingsComponentAttributes : GH_ComponentAttributes
{
public SettingsComponentAttributes(IGH_Component SettingsComponent) : base(SettingsComponent) {}
public override GH_ObjectResponse RespondToMouseDoubleClick(GH_Canvas sender, GH_CanvasMouseEvent e)
{
((SettingsComponent)Owner).ShowSettingsGui();
return GH_ObjectResponse.Handled;
}
}
Welcome to
Grasshopper
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
© 2024 Created by Scott Davidson. Powered by