PushButton not subscribing

For help with anything that CEGUI doesn't offer straight out-of-the-box, e.g.:
- Implementation of new features, such as new Core classes, widgets, WindowRenderers, etc. ...
- Modification of any existing features for specific purposes
- Integration of CEGUI in new engines or frameworks and writing of new plugins (Renderer, Parser, ...) or modules

Moderators: CEGUI MVP, CEGUI Team

User avatar
khariq
Just popping in
Just popping in
Posts: 9
Joined: Mon Mar 21, 2005 14:40

PushButton not subscribing

Postby khariq » Mon Mar 21, 2005 14:48

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;
}

User avatar
CrazyEddie
CEGUI Project Lead
Posts: 6760
Joined: Wed Jan 12, 2005 12:06
Location: England
Contact:

Re: PushButton not subscribing

Postby CrazyEddie » Tue Mar 22, 2005 08:05

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.

Lomir
Just popping in
Just popping in
Posts: 1
Joined: Thu Jun 01, 2006 15:29

Postby Lomir » Thu Jun 01, 2006 18:43

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" />

steego
Just popping in
Just popping in
Posts: 2
Joined: Tue Aug 15, 2006 16:57

Postby steego » Tue Aug 15, 2006 18:23

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

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

Postby Rackle » Tue Aug 15, 2006 20:27

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.

steego
Just popping in
Just popping in
Posts: 2
Joined: Tue Aug 15, 2006 16:57

Postby steego » Tue Aug 15, 2006 21:10

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

User avatar
scriptkid
Home away from home
Home away from home
Posts: 1178
Joined: Wed Jan 12, 2005 12:06
Location: The Hague, The Netherlands
Contact:

Postby scriptkid » Wed Aug 16, 2006 08:12

khariq, have you made the same copy/paste error? ;-)


Return to “Modifications / Integrations / Customisations”

Who is online

Users browsing this forum: No registered users and 4 guests