getting buttons to do something

For help with general CEGUI usage:
- Questions about the usage of CEGUI and its features, if not explained in the documentation.
- Problems with the CMAKE configuration or problems occuring during the build process/compilation.
- Errors or unexpected behaviour.

Moderators: CEGUI MVP, CEGUI Team

jchmack
Just popping in
Just popping in
Posts: 12
Joined: Tue Mar 27, 2007 15:13

getting buttons to do something

Postby jchmack » Mon Apr 02, 2007 17:27

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 =)

Rackle
CEGUI Team (Retired)
Posts: 534
Joined: Mon Jan 16, 2006 11:59
Location: Montréal

Postby Rackle » Mon Apr 02, 2007 19:08

I'm sort of basing this code on the code posted within the Wiki code snippits; look there for more complete code:

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.


Return to “Help”

Who is online

Users browsing this forum: No registered users and 11 guests