Re: Button Callback Arguments



I'm just a newbie and I'm puzzled by the limitations on
arguments to callbacks triggered by a simple button.
It is true that you can only use 2 arguments as in:
void button_callback(GtkWidet * widget, gpointer * data)?

Yes, a button callback has EXACTLY two parameters,
the first is the widget that triggered the event,
(the button) and the second (data) can be anything.

You can pass as many parameters to your callback 
as you wish. The options are:

1) create a structure that contains the parameters
you need, and then pass the structure address
as data.

2) use set_data/get_data to attach parameters to
gtk widgets, as described in: 
www.gtk.org -> API Reference -> Object

3) Use global variables (not recomended).

You should study the examples that come with gtk!
Compile them, modify them, see what happens, this 
is by far the fastest and easiest way to learn GTK!

Carlos




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