[Gtk-sharp-list] How to create a group for Gtk.RadioToolButton ?

Thomas Pryds Lauritsen pryds@duckburg.dk
Thu, 14 Apr 2005 14:20:37 +0200


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Anset and Alain, thank you for your replies

Anset wrote:
| The SList argument of the first ctor is not a problem since, according
| to monodoc;
|
| 	GLib.SList, an existing radio button group, or null
| 	if you are creating a new group.
|
| So just put in null:
|
| button1 = new RadioToolButton(null);
| button2 = new RadioToolButton(button1);

Le Sensei... wrote:
| Toolbar t = new Tollbar();
| RadioToolButton r0 = new RadioToolButton(null); //See previous link
| r0.Label = "label 0";
| t.Add(r0);
| RadioToolButton r1 = new RadioToolButton(r0);

monodoc does indeed say that one can use null in the constructor, but as
I explained in my first mail I already tried this, and it results in a
NullReferenceException and the first button object is not created (if
one catches and ignores the exception).

I ended up solving it this way:

RadioButton g = new RadioButton("g"); // for creating group, not to be shown
RadioToolButton r0 = new RadioToolButton(g.Group);
r0.Label = "button 0";
toolbar.add(r0);
RadioToolButton r1 = new RadioToolButton(g.Group);
r0.Label = "button 1";
toolbar.add(r1);

I.e. I create an ordinary RadioButton, grabs the group from it for use
in the RadioToolButtons and forgets the RadioButton (never add it to the
GUI). Doesn't exactly strike me as an elegant solution, but it seems to
work.

Anset wrote:
| I guess you'd put in the label text using the inherited (from ToolItem)
| "Label" property...

Yep, doing that :-)


Thanks,
Thomas

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.6 (GNU/Linux)

iD8DBQFCXmAV29+7ChTwyPURAs6bAKC9tN3eIxnV3lMJtj/E3xrWJF/gdQCgxvSc
e3OenDUKC0qjCk2E2ii/wfE=
=RWMR
-----END PGP SIGNATURE-----