Am Sonntag, den 14.06.2009, 19:14 -0400 schrieb Christopher Harvey:
> I've got a button signal handler, so it takes no parameters. I was
> wondering if there was some way I could send "user data" when the signal
> is connected.
Sure.
> something like this:
>
> void handlePress(int buttonID) {
> //I use buttonID here
> }
>
> int main() {
> b1.signal_clicked().connect(ptr_fun(handlePress(1)));
> b2.signal_clicked().connect(ptr_fun(handlePress(2)));
> b3.signal_clicked().connect(ptr_fun(handlePress(3)));
> }
Make that:
b1.signal_clicked().connect(sigc::bind(&handlePress, 1)));
b2.signal_clicked().connect(sigc::bind(&handlePress, 2)));
b3.signal_clicked().connect(sigc::bind(&handlePress, 3)));
> Doesn't plain gtk support something like this?
Yes it does. In fact, language bindings in particular make extensive
use of this important feature of the G* APIs. :-)
gtkmm maps GObject signals to sigc++, which is much more powerful and
compile-time type-safe.
--Daniel
_______________________________________________
gtkmm-list mailing list
[email protected]
http://mail.gnome.org/mailman/listinfo/gtkmm-list