我对Gtk.RadioButton
小部件的Clicked
事件有疑问。这是示例代码:
using System;
using Gtk;
public partial class MainWindow: Gtk.Window
{
public MainWindow (): base (Gtk.WindowType.Toplevel)
{
Build ();
RadioButton rbt1 = new RadioButton (null, "rbt1");
RadioButton rbt2 = new RadioButton (rbt1, "rbt2");
RadioButton rbt3 = new RadioButton (rbt1, "rbt3");
VBox vbx1 = new VBox ();
vbx1.PackStart (rbt1, false, false, 0);
vbx1.PackStart (rbt2, false, false, 0);
vbx1.PackStart (rbt3, false, false, 0);
this.Add (vbx1);
this.ShowAll ();
rbt1.Clicked+= HandleClicked;
rbt2.Clicked+= HandleClicked1;
rbt3.Clicked+= HandleClicked2;
}
void HandleClicked2 (object sender, EventArgs e)
{
Console.WriteLine ("rbt3.Clicked");
}
void HandleClicked1 (object sender, EventArgs e)
{
Console.WriteLine ("rbt2.Clicked");
}
void HandleClicked (object sender, EventArgs e)
{
Console.WriteLine ("rbt1.Clicked");
}
}
问题是:
当我单击 rbt2 时,输出为:
rbt1.Clicked
rbt2.Clicked
当我单击 rbt3 时,输出为:
rbt2.Clicked
rbt3.Clicked
当我单击 rbt1 时,输出为:
rbt3.Clicked
rbt1.Clicked
但我期望的是,当我单击 rbt* 时,唯一的输出是“rbt*.Clicked”。