List Info

Thread: Passing arguments to a constructor of a custom widget




Passing arguments to a constructor of a custom widget
user name
2007-08-13 06:47:50
Hi,

I have a class based on Gtk.DrawingArea which I want to use with MonoDevelop's GUI designer. The widget appears in the toolbox so I can drag it onto my form but the autogenerated code doesn't seem to care about the constructor arguments.

My widget needs an instance of another class as a constructor argument:

class MyWidget : Gtk.DrawingArea {
[...]
    public MyWidget(Foo bar) {
    [...]
    }
[...]
}

The autogenerated code doesn't pass any argument like e.g.

myWidget = new MyWidget();

Is there a "nice" solution for this problem? Ideally, I'd like to be able to specify the constructor argument in the widget';s property box (or something similar).

Thanks for your help!

Bonus question: I'm using two different PCs, both with MonoDevelop 0.14. One of them doesn't show MyWidget in the toolbox although I'm using the very same files. MyWidget also appears in the project settings under "GTK# settings" on both systems. Is there anyway to make MonoDevelop refresh the toolbox? Or is this more likely to be a bug?

Regards,
Oliver
Re: Passing arguments to a constructor of a custom widget
user name
2007-08-13 07:09:17
El dl 13 de 08 del 2007 a les 13:47 +0200, en/na Oliver
Battenfeld va
escriure:
> Hi,
> 
> I have a class based on Gtk.DrawingArea which I want to
use with
> MonoDevelop's GUI designer. The widget appears in the
toolbox so I can
> drag it onto my form but the autogenerated code doesn't
seem to care
> about the constructor arguments. 
> 
> My widget needs an instance of another class as a
constructor
> argument:
> 
> class MyWidget : Gtk.DrawingArea {
> [...]
>     public MyWidget(Foo bar) {
>     [...]
>     }
> [...]
> }
> 
> The autogenerated code doesn't pass any argument like
e.g.
> 
> myWidget = new MyWidget();
> 
> Is there a "nice" solution for this problem?
Ideally, I'd like to be
> able to specify the constructor argument in the
widget's property box
> (or something similar). 

Nope, it can't be done. You'll have to change your widget so
that it has
a default constructor.

> 
> Thanks for your help!
> 
> Bonus question: I'm using two different PCs, both with
MonoDevelop
> 0.14. One of them doesn't show MyWidget in the toolbox
although I'm
> using the very same files. MyWidget also appears in the
project
> settings under "GTK# settings" on both
systems. Is there anyway to
> make MonoDevelop refresh the toolbox? Or is this more
likely to be a
> bug? 

Maybe it is a bug, but before filing it you should check
with MD 0.15,
since it might already be fixed.

Lluis.

> 

_______________________________________________
Monodevelop-list mailing list
Monodevelop-listlists.ximian.com
http://lists.ximian.com/mailman/listinfo/monodevelop-li
st

[1-2]

about | contact  Other archives ( Real Estate discussion Medical topics )