Hi everybody,
I'd like to resurrect this quite old Thread because I'm actually trying to do same thing: subscribing member functions to events.
I followed the above code pieces and tried to implement these steps into my project:
Code: Select all
namespace GraphControl{
class InspectableUnit{
public:
bool InspectableUnit::processWAIT(const CEGUI::EventArgs& e){
//do something and return true
}
std::map<std::string, CEGUI::Event::Subscriber> InspectableUnit::getContextMenuEntries(void){
std::map<std::string, CEGUI::Event::Subscriber> entries;
entries.insert(std::pair<std::string, CEGUI::Event::Subscriber>("WAIT", CEGUI::Event::Subscriber(InspectableUnit::processWAIT)));
return entries;
}
//... and then I use this map to subscribe it somewhere else in my project
}
}
This is was is done by the last line in lindquist's code.
When I compile this, the compiler gives an error:
error C3867: "GraphControl::InspectableUnit::processWAIT": Dem Funktionsaufruf fehlt die Argumentliste. Verwenden Sie "&GraphControl::InspectableUnit::processWAIT", um einen Zeiger auf den Member zu erstellen.
(Sorry, for the german explanations. I guess if the message really matters, you can look it up by the error code)
So, I changed the line, as suggested to:
Code: Select all
entries.insert(std::pair<std::string, CEGUI::Event::Subscriber>("WAIT", CEGUI::Event::Subscriber(&GraphControl::InspectableUnit::processWAIT)));
And now it gets interesting. The compiler now complains:
1>c:\program files (x86)\ogre sdk\include\cegui\ceguievent.h(93) : error C2064: Ausdruck ergibt keine Funktion, die 1 Argumente übernimmt
1> c:\program files (x86)\ogre sdk\include\cegui\ceguievent.h(92): Bei der Kompilierung der Klassen-template der bool CEGUI::_functorBinder<Functor,Ret,Args>::operator ()(Args) const-Memberfunktion
1> with
1> [
1> Functor=bool (__thiscall GraphControl::InspectableUnit::* )(const CEGUI::EventArgs &),
1> Ret=bool,
1> Args=const CEGUI::EventArgs &
1> ]
1> c:\program files (x86)\ogre sdk\include\cegui\ceguievent.h(155): Siehe Verweis auf die Instanziierung der gerade kompilierten Klassen-template "CEGUI::_functorBinder<Functor,Ret,Args>".
1> with
1> [
1> Functor=bool (__thiscall GraphControl::InspectableUnit::* )(const CEGUI::EventArgs &),
1> Ret=bool,
1> Args=const CEGUI::EventArgs &
1> ]
1> inspectableunit.cpp(149): Siehe Verweis auf die Instanziierung der gerade kompilierten Funktions-template "CEGUI::SubscriberTemplate<Ret,Args>::SubscriberTemplate<bool(__thiscall GraphControl::InspectableUnit::* )(const CEGUI::EventArgs &)>(const Functor &)".
1> with
1> [
1> Ret=bool,
1> Args=const CEGUI::EventArgs &,
1> Functor=bool (__thiscall GraphControl::InspectableUnit::* )(const CEGUI::EventArgs &)
1> ]
I searched the net about this and it seems to me, that this is an error because of the changes they made in VS 2005 to the member-to-pointer code. But maybe I'm wrong and to dumb to use the Subscriber Template right - in that case, could you please help me out?