[Gtk-sharp-list] Glade signals with GtkSharp handlers
Calvin Gaisford
cgaisford@novell.com
Tue, 03 Feb 2004 08:18:29 -0700
Joe,
You need to sub-class the EventArgs class. Something like this:
public class MyEventArgs : EventArgs
{
private readonly string str;
public MyEventArgs(string str)
{
this.str = str;
}
public string StrValue
{
get { return str;}
}
}
You can delare your delegate like this:
public delegate void MyEventHandler(object sender, MyEventArgs args);
In the class you want to signal the event declare the event something
like this:
public event MyEventHandler MyEventName;
To signal the event in your class do something like this:
MyEventArgs args = new MyEventArgs("Whatever String I am passing");
MyEventName(this, args);
A class connecting to your event would declare a handler like this:
public void OnMyEventName(object o, MyEventArgs args)
{
string eventString = args.StrValue;
}
and they would connect their handler to your delegate like this:
whateverobject.MyEventName += new MyEventHandler(OnMyEventName);
I hope that helps.
-Calvin
On Mon, 2004-02-02 at 18:43, Joe Scaduto wrote:
> Hi,
>
> I am using Glade 2 to create my base application "look and feel" and I
> want to connect a signal to a handler in my gtksharp application but I
> need to pass extra data to the handler (such as a string). From what I
> have been told the 'Object' field in Glade 2 allows you to pass whatever
> data to a handler you want but I am not sure how to get this data in a
> gtksharp signal handler. I only know of 2 parameters for the handler:
>
> public someHandler (object o, EventArgs args)
> {}
>
> Any information would be greatly appreciated
>
> Thanks,
>
> Joe
>
> _______________________________________________
> Gtk-sharp-list maillist - Gtk-sharp-list@lists.ximian.com
> http://lists.ximian.com/mailman/listinfo/gtk-sharp-list