CEGUI buttons not subscribing to events?

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

pighead10
Just popping in
Just popping in
Posts: 8
Joined: Fri Jan 21, 2011 15:43

CEGUI buttons not subscribing to events?

Postby pighead10 » Wed Nov 30, 2011 22:24

When the class is initiated, a GUI layout is loaded and subscribed using the line:

Code: Select all

guiRoot->getChild("Root/AddMiner")->subscribeEvent(CEGUI::PushButton::EventClicked,CEGUI::Event::Subscriber(&GameState::addMiner,this));

which works fine. However, it is then swapped, changing the layout and subscribing the layout using this:

Code: Select all

void GameState::showSelectedLayouts(UnitManager* teamMgr){
   if (mSelectedObjects.size() >= 1){
      CEGUI::WindowManager::getSingleton().destroyWindow(guiRoot);
      guiRoot = CEGUI::WindowManager::getSingleton().loadWindowLayout(teamMgr->nodeBeingTracked(mSelectedObjects[0])->LayoutName);
      //TODO: make this show a blank GUI if different types get selected at once
      CEGUI::System::getSingleton().setGUISheet(guiRoot);
      guiRoot->activate();
      
      //subscribe events
      if(guiRoot->isChild("Root/AddMiner")){
         guiRoot->getChild("Root/AddMiner")->subscribeEvent(CEGUI::PushButton::EventClicked,CEGUI::Event::Subscriber(&GameState::addMiner,this));
      }else if(guiRoot->isChild("Root/BuildBridge")){
         guiRoot->getChild("Root/BuildBridge")->subscribeEvent(CEGUI::PushButton::EventClicked,CEGUI::Event::Subscriber(&GameState::buildBridge,this));
      }
   }
}

The correct layout is shown, but the button - Root/BuildBridge - doesn't subscribe. Furthermore, when using that function to swap back and subscribe to the originally select layout/button (Root/AddMiner) that doesn't work either. By the events not working, I mean the function doesn't even run (addMiner or addBridge).

Thanks

Return to “Help”

Who is online

Users browsing this forum: No registered users and 10 guests