Re: Events and signals
- From: Jeff Franks <jcf tpg com au>
- To: Fabio Zanetta <znt fabio virgilio it>
- Cc: "GTK2.0" <gtk-app-devel-list gnome org>
- Subject: Re: Events and signals
- Date: Mon, 25 Nov 2002 13:54:48 +1100
Fabio Zanetta wrote:
Hi,
Here another distinguish-question :)
What is the difference between events and signals?
Events correspond to the events in the X event mechanism and are
declared in gdkevents.h. They are more low level. Signals are defined by
widgets and are used to signal that something has happend to the
widget. At which point a widget will pass control to any connected
callback functions. For convenience, GtkWidget wraps the GDK (X) events
in a signal. These signals are suffixed with "_event". You can connect
to events and signals in the same way, with g_signal_connect(). Events
pass an event struct to connected callack functions that often contains
extra information, like x and y cursor cordinates in GdkButtonEvent.
Why I sould use g_signal_connect() instead of gtk_widget_set_events()?
You must use g_signal_connect() to connect to events and signals. You
would use gtk_widget_set_events() when you want to set the events a
widget will receive. Most widgets have a default set of events they
receive. If you want to receive extra events you would call
gtk_widget_set_events() if the widget has not been realized, and
gtk_widget_add_events() if it has. Be careful though, you might change
the way a widget behaves, for better or worse.
And how can I trap a event? (with signals I can use a callback function...
but with events?)
You can use callback functions, in the same way, just use the right
callback function signature.
And also... for a Button I can only find out the "clicked" signal... there
are others? Where can I find docs on it?
Look in the reference docs in your source directory, docs directory or
online and you will find "gtk/gtkbutton.html" and "gdk/gdk-events.html".
gtkbutton.html lists the button signals and what they mean.
gdk-events.html lists all the events and what they mean.
Can I know if a widget can accept or not the "xyz" signal?
A widget inherits the signals of the widget it derives from. So look at
the reference docs for the widget you're interested in. The signals are
listed at the bottom of the page. Then look at the its parent, and its
parent, and so on. Although a widget inherits a signal from its parent,
its default response to the signal might be different.
Jeff Franks.
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]