Page 1 of 1

FAQ wiki problem

Posted: Sat Aug 05, 2006 02:37
by kiolakin
Just thought someone might want to correct this...

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
    PushButton* mButton;

    MyButtonHandler::MyButtonHandler(PushButton* btn) : mButton(btn)
        btn->subscribeEvent(PushButton::EventClicked, Event::Subscriber(MyButtonHandler::ButtonClicked,this));
        //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]

Posted: Sat Aug 05, 2006 06:42
by lindquist
thanx for the report