Thursday, December 3, 2009

Tut 5: Callbacks with GTKmm


So far, we've told the computer what to do, and then let it do it.
But what if we want it to execute some code ONLY when we do something
first? The best solution to this "problem" is something called Callback Functions.

We've actually already used callbacks before. Remember back in Tut 3,
we had 'jack_set_process_callback ();' ? There you go.

GTKmm uses the SigC++ library to handle its callbacks. This means that when the user clicks a button, sigc++ comes into action, and "sends" a signal called signal_clicked(). Then we can connect this signal to a function. Eg: when we recieve signal_clicked(), we tell the program to do function X.

Download the code for a working example, and maybe read the GTKmm book if you want to know more about signals.

No comments:

Post a Comment