Page 1 of 1

PushButton not subscribing

Posted: Mon Mar 21, 2005 14:48
by khariq
I'm trying to put a button on the gui to start an ogre animation. The MouseEnters and Leaves events register and firing correctly, but the button push does not. Below is the code, any help would be greatly appreciated.

Code: Select all

CEGUI::Window* sheet = CEGUI::WindowManager::getSingleton().loadWindowLayout((CEGUI::utf8*)"gui.xml");
   mGUISystem->setGUISheet(sheet);

   try
   {
      CEGUI::WindowManager& wmgr = CEGUI::WindowManager::getSingleton();
      wmgr.getWindow((CeStr)"StartButton")
         ->subscribeEvent(
            CEGUI::PushButton::EventClicked,
            CEGUI::Event::Subscriber(&MarchDemo::startAnimation, this)
            );
      wmgr.getWindow((CeStr)"StartButton")
         ->subscribeEvent(
         CEGUI::Window::EventMouseEnters,
         CEGUI::Event::Subscriber(&MarchDemo::handleMouseEnters, this)
         );
      wmgr.getWindow((CeStr)"StartButton")
         ->subscribeEvent(
         CEGUI::Window::EventMouseLeaves,
         CEGUI::Event::Subscriber(&MarchDemo::handleMouseExits, this)
         );
   }
   catch (CEGUI::UnknownObjectException e)
   {
      MessageBox(NULL, e.getMessage().c_str(), "Error", MB_OK);
   }
///More misc code
bool MarchDemo::startAnimation(const CEGUI::EventArgs& e)
{
   MessageBox(NULL, "Button Clicked", "", MB_OK);
   mController->startAnimation();
   return true;
}

bool MarchDemo::handleMouseEnters(const CEGUI::EventArgs& e)
{
   MessageBox(NULL, "Testing", "", MB_OK);

   mController->setGUIActive(true);
   return true;
}

bool MarchDemo::handleMouseExits(const CEGUI::EventArgs& e)
{
   mController->setGUIActive(false);
   return true;
}

Re: PushButton not subscribing

Posted: Tue Mar 22, 2005 08:05
by CrazyEddie
This is a strange one, the code looks good. Do you have any other information that might be useful? I assume there's nothing in the log as your other handlers are getting subscribed correctly.

I'll keep thinking and get back to you if anything comes to mind :?

CE.

Posted: Thu Jun 01, 2006 18:43
by Lomir
I've got the same problem with Ogre 1.2 [Dagon].
It's really very strage, cause I am just learing Ogre and CEGUI and took code almost only from turtorials...
Same as khariq, mouse exiting and entering the button zone responds corectly.

khariq, have you solved you problem? How?

Code: Select all

ButtonLoading:
mGUIWindow_EditorGuiSheet_IS = CEGUI::WindowManager::getSingleton().loadWindowLayout(
      (CEGUI::utf8*)"MainMenuGui.xml");
mGUISystem_IS=gm->getGUISystem();
mGUISystem_IS->setGUISheet(mGUIWindow_EditorGuiSheet_IS);

Attachment:
wmgr.getWindow((CEGUI::utf8*)"Quit")->subscribeEvent(
         CEGUI::PushButton::EventClicked, CEGUI::Event::Subscriber(&IntroState::handleQuit, this));

Function:
bool IntroState::handleQuit(const CEGUI::EventArgs& e)
{
   quitingTheGame = true;
   return true;
}

SelfButton:
<Window Type="TaharezLook/Button" Name="Quit">
<Property Name="RelativeRect" Value="l:0.650000 t:0.550000 r:0.950000 b:0.650000" />
<Property Name="Text" Value="Quit" />

Posted: Tue Aug 15, 2006 18:23
by steego
I also have this, I downloaded Ogre 1.2 recently and couldn't figure out what I did wrong.

Neither PushButton::EventClicked nor EventMouseClick seems to work, but I can bind EventMouseButtonDown without problems (using the same syntax). MouseEnters and Leaves also works fine.

I don't get any errors using EventClicked, and there is nothing reported in the log (insane level) - my function just isn't called.


Edit: There is ofcourse something in the log, but no errors or anything I can relate to this. (Tought that might be unclear upon re-reading my post.)

Posted: Tue Aug 15, 2006 20:27
by Rackle
The end code (the Cegui code) looks fine. So let's go at the start, where you inject the mouse clicks. Are you using OIS or Ogre's default input system? How are you converting the button IDs, the button numbers? Please post that code.

Posted: Tue Aug 15, 2006 21:10
by steego
Hoho, I wrote a long post and included all sorts of code, and lo and behold, when I look at the preview I spot my error. I should have known it was a lazy copy-paste error - I called injectMouseButtonDown in both my mousePressed and mouseReleased functions... :oops:

Thanks for putting me on the right track tough :D

Posted: Wed Aug 16, 2006 08:12
by scriptkid
khariq, have you made the same copy/paste error? ;-)