I'm trying to make a widget with 9 toggle-buttons (3 rows and 3 columns), the user shall be able to select one of those. So i wrote 9 event handlers, which disabled the currently selected button and store the selection.
I just wanted to know if there is any way to connect those 9 toggle buttons to one single handler, and if there is a way to know which button emitted the signal. Something similar to QT's
QObject::sender()
This would avoid a lot of repetition in my code. As noted in the title I am using gtkmm version 2 and of course sigc++.
Thank you in advice
I've used c++11 lambdas to solve a similar problem. Basically you capture the information about the target in the lambda so when the signal fires you can do something target specific. For example:
I believe this will work with gtkmm 2.x, but I have only used it with 3.0 and I don't know how sigc++ has changed between the two versions. If you can't use c++11 features, you might be able to do something similar with the lambda functionality that comes with sigc++, but I've no experience with it.