[Date Prev][Date Next] [Thread Prev][Thread Next]
[Thread Index]
[Date Index]
[Author Index]
Re: passing data to Menu handler function
- From: Gustavo Joćo Alves Marques Carneiro <ee96090 fe up pt>
- To: gtk-app-devel-list redhat com
- Subject: Re: passing data to Menu handler function
- Date: Tue, 26 Oct 1999 21:52:08 +0100 (WET)
On Tue, 26 Oct 1999, Carlos Pereira wrote:
> Dear all,
> Typically, the event_handler to pop up a menu looks like this:
>
> static gint button_press_handler (GtkWidget *widget, GdkEvent *event)
> { .
> gtk_menu_popup (menu, ...
> .
> }
>
> Now the question is, how can I pass data to this function (not talking of
> external variables of course)? When I try a function with three arguments
> static gint button_press (GtkWidget *widget, GdkEvent *event, gpointer data)
> I always get errors. In fact, all the examples I see use a signal_connect_object
> function, where the object is the menu, which makes it difficult to pass a gpointer...
>
Sometimes it's useful to do a 'gtk_signal_connect_object', but you
probably want just 'gtk_signal_connect', in which case you can pass any
pointer as the 'data' argument to gtk_signal_connect. That pointer will be
passed to your callback function as its last argument.
If you *have* to use 'gtk_signal_connect_object', then you cannot
pass any data pointers to the function. In that case, you should attach
data to the object the receives the event (the last GTK_OBJECT(..) in
'gtk_signal_connect_object'), with 'gtk_object_set_data'.
> Thanks for the help!
>
> Carlos
>
>
>
--
Gustavo J.A.M. Carneiro
World::Portugal::FEUP::DEEC::LEEC::TEC
[reinolinux.fe.up.pt/~ee96090]
[Date Prev][Date Next] [Thread Prev][Thread Next]
[Thread Index]
[Date Index]
[Author Index]