зеркало из https://github.com/mono/mail-archives.git
139 строки
4.6 KiB
HTML
139 строки
4.6 KiB
HTML
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
|
|
<HTML>
|
|
<HEAD>
|
|
<TITLE> [Gtk-sharp-list] Glade signals with GtkSharp handlers
|
|
</TITLE>
|
|
<LINK REL="Index" HREF="index.html" >
|
|
<LINK REL="made" HREF="mailto:scooch%40noggle.biz">
|
|
<META NAME="robots" CONTENT="index,nofollow">
|
|
|
|
<LINK REL="Previous" HREF="003311.html">
|
|
<LINK REL="Next" HREF="003306.html">
|
|
</HEAD>
|
|
<BODY BGCOLOR="#ffffff">
|
|
<H1>[Gtk-sharp-list] Glade signals with GtkSharp handlers
|
|
</H1>
|
|
<B>Joe Scaduto
|
|
</B>
|
|
<A HREF="mailto:scooch%40noggle.biz"
|
|
TITLE="[Gtk-sharp-list] Glade signals with GtkSharp handlers">scooch@noggle.biz
|
|
</A><BR>
|
|
<I>Tue, 03 Feb 2004 16:25:56 -0500</I>
|
|
<P><UL>
|
|
<LI> Previous message: <A HREF="003311.html">[Gtk-sharp-list] Glade signals with GtkSharp handlers
|
|
</A></li>
|
|
<LI> Next message: <A HREF="003306.html">[Gtk-sharp-list] Gtk-sharp on OS X
|
|
</A></li>
|
|
<LI> <B>Messages sorted by:</B>
|
|
<a href="date.html#3314">[ date ]</a>
|
|
<a href="thread.html#3314">[ thread ]</a>
|
|
<a href="subject.html#3314">[ subject ]</a>
|
|
<a href="author.html#3314">[ author ]</a>
|
|
</LI>
|
|
</UL>
|
|
<HR>
|
|
<!--beginarticle-->
|
|
<PRE>Calvin,
|
|
|
|
This definitively helps in my understanding of event handlers however, I
|
|
should have mentioned that I am connecting the handlers via Glade#.
|
|
|
|
example:
|
|
|
|
Glade.XML gxml = new Glade.XML (null,"file.glade", "window2", null);
|
|
gxml.Autoconnect (this);
|
|
|
|
So I am still not sure how I would be able to pass a string?
|
|
|
|
Joe
|
|
|
|
On Tue, 2004-02-03 at 10:18, Calvin Gaisford wrote:
|
|
><i> Joe,
|
|
</I>><i>
|
|
</I>><i> You need to sub-class the EventArgs class. Something like this:
|
|
</I>><i>
|
|
</I>><i> public class MyEventArgs : EventArgs
|
|
</I>><i> {
|
|
</I>><i> private readonly string str;
|
|
</I>><i>
|
|
</I>><i> public MyEventArgs(string str)
|
|
</I>><i> {
|
|
</I>><i> this.str = str;
|
|
</I>><i> }
|
|
</I>><i>
|
|
</I>><i> public string StrValue
|
|
</I>><i> {
|
|
</I>><i> get { return str;}
|
|
</I>><i> }
|
|
</I>><i> }
|
|
</I>><i>
|
|
</I>><i> You can delare your delegate like this:
|
|
</I>><i>
|
|
</I>><i> public delegate void MyEventHandler(object sender, MyEventArgs args);
|
|
</I>><i>
|
|
</I>><i> In the class you want to signal the event declare the event something
|
|
</I>><i> like this:
|
|
</I>><i>
|
|
</I>><i> public event MyEventHandler MyEventName;
|
|
</I>><i>
|
|
</I>><i> To signal the event in your class do something like this:
|
|
</I>><i>
|
|
</I>><i> MyEventArgs args = new MyEventArgs("Whatever String I am passing");
|
|
</I>><i> MyEventName(this, args);
|
|
</I>><i>
|
|
</I>><i> A class connecting to your event would declare a handler like this:
|
|
</I>><i>
|
|
</I>><i> public void OnMyEventName(object o, MyEventArgs args)
|
|
</I>><i> {
|
|
</I>><i> string eventString = args.StrValue;
|
|
</I>><i> }
|
|
</I>><i>
|
|
</I>><i> and they would connect their handler to your delegate like this:
|
|
</I>><i>
|
|
</I>><i> whateverobject.MyEventName += new MyEventHandler(OnMyEventName);
|
|
</I>><i>
|
|
</I>><i> I hope that helps.
|
|
</I>><i>
|
|
</I>><i> -Calvin
|
|
</I>><i>
|
|
</I>><i>
|
|
</I>><i> On Mon, 2004-02-02 at 18:43, Joe Scaduto wrote:
|
|
</I>><i> > Hi,
|
|
</I>><i> >
|
|
</I>><i> > I am using Glade 2 to create my base application "look and feel" and I
|
|
</I>><i> > want to connect a signal to a handler in my gtksharp application but I
|
|
</I>><i> > need to pass extra data to the handler (such as a string). From what I
|
|
</I>><i> > have been told the 'Object' field in Glade 2 allows you to pass whatever
|
|
</I>><i> > data to a handler you want but I am not sure how to get this data in a
|
|
</I>><i> > gtksharp signal handler. I only know of 2 parameters for the handler:
|
|
</I>><i> >
|
|
</I>><i> > public someHandler (object o, EventArgs args)
|
|
</I>><i> > {}
|
|
</I>><i> >
|
|
</I>><i> > Any information would be greatly appreciated
|
|
</I>><i> >
|
|
</I>><i> > Thanks,
|
|
</I>><i> >
|
|
</I>><i> > Joe
|
|
</I>
|
|
|
|
|
|
|
|
</PRE>
|
|
<!--endarticle-->
|
|
<HR>
|
|
<P><UL>
|
|
<!--threads-->
|
|
<LI> Previous message: <A HREF="003311.html">[Gtk-sharp-list] Glade signals with GtkSharp handlers
|
|
</A></li>
|
|
<LI> Next message: <A HREF="003306.html">[Gtk-sharp-list] Gtk-sharp on OS X
|
|
</A></li>
|
|
<LI> <B>Messages sorted by:</B>
|
|
<a href="date.html#3314">[ date ]</a>
|
|
<a href="thread.html#3314">[ thread ]</a>
|
|
<a href="subject.html#3314">[ subject ]</a>
|
|
<a href="author.html#3314">[ author ]</a>
|
|
</LI>
|
|
</UL>
|
|
</body></html>
|