[Gtk-sharp-list] Returning Gdk.Events
Miguel de Icaza
miguel@ximian.com
11 Mar 2003 14:12:03 -0500
Hello!
> My suggested solution is to use something like:
>
> public static Gdk.Event CurrrentEvent {
> IntPtr handle = gtk_get_current_event ();
> GdkEventType type;
>
> type = (GdkEventType)Marshal.Read32 (handle);
> switch (type) {
> case GdkEventType.Expose:
> return (Gdk.Event)Marshal.PtrToStructure (handle, typeof (Gdk.EventExpose));
> case GdkEventType.ButtonPress:
> return (Gdk.Event)Marshal.PtrToStructure (handle, typeof (Gdk.ButtonPress));
> ...
> }
> }
>
> Modulo some small details, it should work nicely.
There is only one problem here: Gdk.Event is a class, and the various
Gdk.EventXXXX are structures that do not share a common base class.
I could change the signature to return an `object' instead of a
Gdk.Event, and it would be up to the user to do an `is' compare on the
result.
Miguel