getting buttons to do something
Moderators: CEGUI MVP, CEGUI Team
getting buttons to do something
im new to cegui. I have been going over the beginners tutorials and i can get my button on screen and am injecting inputs properly. I can click the button and it changes to its "pushed in" state. But where do i define what this does in my program? Where can i say when i push button x (in CEGU) perform action y? Looking at the tutorials (from what i can find) the beginners guide ends at injecting inputs then goes into scripting and artists content. Can someone inform me or point to a link on how to get actions back from CEGUI? Thanks a lot in advance guys =)
I'm sort of basing this code on the code posted within the Wiki code snippits; look there for more complete code:
Basically you subscribe to an event, such as a pushbutton being clicked and specify which class function should be called. In that function you execute your code and return true.
Code: Select all
class MyClass : public DialogSystem
{
public:
bool initialiseSample()
{
...
CEGUI::Window* widgetHandle = CEGUI::WindowManager::getSingleton().getWindow(widget);
widgetHandle->subscribeEvent(CEGUI::PushButton::EventClicked, CEGUI::Event::Subscriber(&MyClass::onOk, this));
...
return true;
}
bool onOk(const CEGUI::EventArgs& e)
{
// THE BUTTON WAS CLICKED!!!
return true;
}
}
Basically you subscribe to an event, such as a pushbutton being clicked and specify which class function should be called. In that function you execute your code and return true.
Who is online
Users browsing this forum: No registered users and 14 guests