[Date Prev][Date Next] [Thread Prev][Thread Next]
[Thread Index]
[Date Index]
[Author Index]
Re: GTK Signal
- From: Havoc Pennington <rhpennin midway uchicago edu>
- To: gtk-app-devel-list redhat com
- Subject: Re: GTK Signal
- Date: Fri, 6 Nov 1998 10:00:19 -0600 (CST)
On Fri, 6 Nov 1998, Eric Faurot wrote:
> hack@altavista.net wrote:
> >
> > Hi folks,
> >
> > When I was trying to make a gtk_signal_connect (by a button_press_event of a gtk_event_box (!!)), I wasn't able to pass an int to the ButtonPressed function:
> >
> > ... GTK_SIGNAL_FUNC (ButtonPressed), (gint) ibutton);
>
> You should pass a pointer as an argument.
> Either pass a pointer to that int or cast that int
> into a pointer (beware of the size of your int)
> Then recover it properly in your handler...
>
This is good practice but probably not the problem.
Event handlers take a second arg, GdkEventButton, then the user data is
the third arg. i.e.
ButtonPressed(GtkButton*, GdkEventButton*, gpointer data)
So you are getting the event pointer instead of your int.
In general signals have all kinds of different signatures, you need to
check the signature in the Class struct of the object you are connecting
to. To get the full signature, you can always assume a 'gpointer data'
after the stuff in the class struct declaration.
There are also GPOINTER_TO_INT() and vice versa macros to make the
int-passing more convenient.
Havoc
[Date Prev][Date Next] [Thread Prev][Thread Next]
[Thread Index]
[Date Index]
[Author Index]