|
One other thing I didn't clarify... The reason when you connect to "button-press-event" nothing happens, that's because the function prototype (as described in the API docs for GtkWidget) is different. It has 3 parameters: (GtkWidget *widget, GdkEventButton *event, gpointer user_data) Where your 'Happened' function only has 2 parameters. When you're starting out, it's easiest to build your prototypes for callbacks exactly as they appear in the API. That way you know what you're dealing with. gboolean on_button_press_event (GtkWidget *widget, GdkEventButton *event, gpointer user_data) { g_print ("on_button_press_event: %s", (gchar*)user_data); return FALSE; /* propogate signal to default handlers */ } void on_pressed (GtkWidget *widget, gpointer user_data) { g_print ("on_pressed: %s", (gchar*)user_data); return FALSE; /* propogate signal to default handlers */ } /* ... down in main() ... */ GtkWidget *B = gtk_button_new_with_label (Label); g_signal_connect (GTK_OBJECT (B), "button-press-event", G_CALLBACK (on_button_press_event), "The mouse was clicked on a GtkWidget."); g_signal_connect (GTK_OBJECT (B), "button-press-event", G_CALLBACK (on_pressed), "The button was pressed on a GtkButton."); - Micah Carrick Developer - http://www.micahcarrick.com GTK+ Forums - http://www.gtkforums.com Micah Carrick wrote: Start with the API documentation for a GtkButton: http://library.gnome.org/devel/gtk/stable/GtkButton.html Scroll down to "Signals" to see each signal you can connect a callback to for a GtkButton as well as the prototype for writing such a callback function. That is where "pressed" is coming from... the GtkButton. You can also look at the section called "Object Hierarchy" in the API to see which objects a GtkButton is derived from. You can also use the signals for any of those objects. If you were to click on GtkWidget, you'll find the "button-press-event" signal there with the description: " The ::button-press-event signal will be emitted when a button (typically from a mouse) is pressed." So as you can see, the "pressed" signal from GtkButton is what you want to connect to for a user clicking a button. If you want to capture the mouse clicking on a widget... any widget... you use "button-press-event". Whenever you find a signal that you don't know to which object it belongs, one easy way out is to search for it in Devhelp. - Micah Carrick Developer - http://www.micahcarrick.com GTK+ Forums - http://www.gtkforums.com Charles Packer wrote: |