[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: reading event in signal handler callback



Am Di, den 30.03.2004 schrieb Tristan Van Berkom um 19:15:
> Marc Santhoff wrote:
> > Hi,
> > 
> > I need to know how i can get access to the event, that caused the signal
> > handler to be called.
> > 
> > The handler is (of course) defined as GtkSignalFunc. In the handler I
> > want to discriminate different event types, not only emitters.
> > 
> > How can this be done?
> See:
> http://developer.gnome.org/doc/API/2.0/gdk/gdk-Event-Structures.html
> 
> A GdkEvent is a union of structures, all of which have the first member
> "GdkEventType" (which is also one of the union members).
> 
> So, upon recieval of, for example, a GdkEventKey; you can cast it
> to a GdkEventType and check for GDK_KEY_PRESS/GDK_KEY_RELEASE.
> you can also simply check the value of event->type (it is the first
> member in any of those structures).
> 
> Note that this only applies to signals that dispatch events (i.e. signals
> definied by the GtkWidgetClass). It is logical to say that a "pressed"
> signal of the GtkButtonClass was a result of mouse clicks, but IMO, it's
> incorrect, the GtkButtonClass is the sole responsable actor who decides
> when its button is "pressed" (it could also be a result of the programmer
> calling the function gtk_button_pressed() for example).

Uh oh, I forgot to write that I'm using GTK+1.2. GtkSignalFunc is
defined as:

void        (*GtkSignalFunc)

and the only thing to attach by the emitter is a data pointer.

I found GtkWidget has a definition:

gtk_widget_event ()

but according to the sources this is for emitting signals, not for
querying the last one received ...

Bye,
Marc





[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]