Re: g_signal_connect -- "button-press-event" vs "pressed"



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:
If I code a button widget like this (I'm using the version
of GTK that came with Fedora Core 5)...

	GtkWidget *B = gtk_button_new_with_label (Label);
	g_signal_connect (GTK_OBJECT (B), "button-press-event",
                G_CALLBACK (Happened), "HELLO");

and the callback is this...

	Happened (GtkWidget *W, gpointer Data) {
		g_print ("ButtonHappened...|%s|\n", (char *) Data);
	}

when Happened is executed, it doesn't print the data. That is, I get "ButtonHappened...||". But when I replace the parameter "button-press-event" in the call to g_signal_connect with "pressed", on execution the printout is as desired, "ButtonHappened...|HELLO|". Now, "button-press-event" is in lists of event types such as you find in the GTK 2.0 tutorial at http://www.gtk.org/tutorial/a2769.html

As for "pressed", I don't know where I got it. It must have come along with some example I found in a newsgroup or on the Web. I haven't been able to find an event-type list anywhere that contains it, so I can't solve the mystery of why I get what I want when I use that parameter, but not with the "legitimate" parameter.

-- Charles Packer
http://cpacker.org/whatnews
mailboxATcpacker.org _______________________________________________
gtk-list mailing list
gtk-list gnome org
http://mail.gnome.org/mailman/listinfo/gtk-list



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