[gtkmm] Function pointers question (gtkmm related)



Hi all,

I am having a small problem implementing the callback functions for menu items, toolbar buttons, etc:

My current code looks like this:

------------------------------------------------------------

class MyToolbar:Gtk::Toolbar {
 public:
 MyToolbar();
 private:
 AnotherClass* anotherObject;
};

class OtherClass {
 public: doStuff();
};

MyToolbar::MyToolbar() {
 ...
 push_back(StockElem(Gtk::Stock::NEW,
   SigC::slot(*this, &MyToolbar::newButtonClicked),  "New"));
 ...
}

//callback function
MyToolbar::newButtonClicked() {
 //do stuff
 otherObject->doStuff();
}

------------------------------------------------------------


What I'm after, is to be able to pass a method belonging to another object, in a similar method to this (which doesn't compile):


------------------------------------------

MyToolbar::MyToolbar() {
 ...
 push_back(StockElem(Gtk::Stock::NEW,
   SigC::slot(*this, &OtherClass::newButtonClicked),  "New"));
 ...
}

---------------------------------------------

Is this possible, or will I have to stick with the method that I am currently using?


Thanks in advance.

_________________________________________________________________
Hot chart ringtones and polyphonics. Go to http://ninemsn.com.au/mobilemania/default.asp




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