Subscribing Events with Inherited classes
Posted: Fri Sep 05, 2008 00:22
Hello,
I have a class NurikabeGUI, which inherits from BoardGUI. Inside BoardGUI I have the function:
I am trying to subscribe a button to this callback in the NurikabeGUI constructor. I first tried:
which gives me the errors:
I then tried
since 'this' is an instance of NurikabeGUI. In this case, I get the second error as above, but not the first.
So I suppose my question is this: Is it possible to use an inherited function as a callback?
Thanks in advance!
Kevin
I have a class NurikabeGUI, which inherits from BoardGUI. Inside BoardGUI I have the function:
Code: Select all
bool BoardGUI::checkClicked(const CEGUI::EventArgs& args)
{
...
return true;
}
I am trying to subscribe a button to this callback in the NurikabeGUI constructor. I first tried:
Code: Select all
_checkButton->subscribeEvent(CEGUI::PushButton::EventClicked, CEGUI::Event::Subscriber(&BoardGUI::checkClicked, this));
which gives me the errors:
Code: Select all
c:\Progs\PencilPuzzles\NurikabeGUI.cpp(24): error C2248: 'Penpa::BoardGUI::checkClicked' : cannot access protected member declared in class 'Penpa::BoardGUI'
Code: Select all
c:\Progs\PencilPuzzles\NurikabeGUI.cpp(24): error C2661: 'CEGUI::SubscriberSlot::SubscriberSlot' : no overloaded function takes 2 arguments
I then tried
Code: Select all
_checkButton->subscribeEvent(CEGUI::PushButton::EventClicked, CEGUI::Event::Subscriber(&NurikabeGUI::checkClicked, this));
since 'this' is an instance of NurikabeGUI. In this case, I get the second error as above, but not the first.
So I suppose my question is this: Is it possible to use an inherited function as a callback?
Thanks in advance!
Kevin