问题
I get the following error on the code below:
expected class,delegate,enum,interface or struct.
This happens when hovering on GH_ObjectResponse, what am I doing wrong?
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;
}
回答1:
Your method is not declared inside the class... try this instead:
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;
}
}
回答2:
Watch your brackets. It should be:
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;
}
}
来源:https://stackoverflow.com/questions/11769866/error-expected-class-delegate-enum-interface-or-struct