FAQ wiki problem
Posted: Sat Aug 05, 2006 02:37
Just thought someone might want to correct this...
should be:
which is not a huge deal, but it may be enough to confuse someone.[/quote]
What is the correct way to subscribe for an event?
Event notification is a vital aspect of GUI programming. CEGUI handles those using subscribers. In order to subscribe a window for an event, you have to call the method 'Window::subscribeEvent', passing the function to be called when the specified event occurs, and the instance on which the method is called.Code: Select all
class MyButtonHandler
{
private:
PushButton* mButton;
public:
MyButtonHandler::MyButtonHandler(PushButton* btn) : mButton(btn)
{
btn->subscribeEvent(PushButton::EventClicked, Event::Subscriber(MyButtonHandler::ButtonClicked,this));
}
MyButtonHandler::ButtonClicked()
{
//This function gets called when the button is clicked
std::cout << "Button clicked" << std::endl;
}
should be:
Code: Select all
bool MyButtonHandler::ButtonClicked(const EventArgs &e)
which is not a huge deal, but it may be enough to confuse someone.[/quote]