Page 1 of 1

Button fails to activate

Posted: Sat Oct 10, 2009 10:08
by Nomonkeybusiness
Hi all!
So I've got two layouts loaded into my program. The first takes care of different windows on the sides of the screen, a chatbox and a combatlog and some other stuff.
The other layout is a window that contains a bunch of buttons. A sort of commandcenter. Right now, I have one button on the commandcenter, and it is definately set to enabled and visible.
The problem is that it doesn't seem active, because the image doesn't change on hover, and the callback is never executed. In debug, I can clearly see that the commandcenter is active.
What has happened?

ps. I'm using version 0.6.3 ds.

EDIT: Nevermind, I solved it. Apparently I had to activate it to.

Another problem arises though. The callback-function is a memberfunction from a class called DeploymentState.
This is what I do when I initialize the button:

Code: Select all

CEGUI::Window* pWnd = pSquadWindow->getChildAtIdx(i);
if(i < pForce->getNumSquads())
{
   pWnd->setID(SquadList.at(i)->getSquadID());
   BindButtonToFunction(pWnd, CEGUI::Event::Subscriber(&Deployment::btnPickSquad, m_pDeployment));
   pWnd->enable();
   pWnd->setVisible(true);
   pWnd->activate();
   m_SquadSelectionButtons.push_back(pWnd);
} else
{
   pWnd->disable();
   pWnd->setVisible(false);
}

Code: Select all

void BindButtonToFunction(CEGUI::Window* pWnd, CEGUI::Event::Subscriber& subscriber)
{
   pWnd->subscribeEvent(CEGUI::PushButton::EventMouseClick, &subscriber)
}


Why does not this work?

Edit: Forgot to tell you. The error is in the function

Code: Select all

virtual bool operator()(const EventArgs& args)
{
        return (*d_functor)(args);
}

in the header ceguifunctorpointerslot.h, and it seems that d_functor is equal to NULL.

Re: Button fails to activate

Posted: Sat Oct 10, 2009 10:24
by CrazyEddie
HI,

It sounds like you have transparent parts of windows - or multiple full-screen DefaultWindow root windows - overlapping and preventing visible content beneath from being 'hit'. To alleviate this you should ensure that all of your DefaultWindow roots have the "MousePassThroughEnabled" property set to "True" - with the exception of the actual root, which you set with setGUISheet (only applies to 0.6.x code so you can listen to events on that root if you need to)

[Edit]
The above is maybe not relevant now, and certainly does not answer the functor issue edit.

CE.

Re: Button fails to activate

Posted: Sat Oct 10, 2009 10:50
by Nomonkeybusiness
Thanks a lot. MousePassThrough ofcourse took care of the first problem. Have you got a clue on why the callback-linking does not work? I send an instance of cDeploymentState along with the function, so it should work...
or should it? That is only my reaction to the function-description.
"SubscriberSlot (bool(T::*function)(const EventArgs &), T *obj)
Creates a SubscriberSlot that is bound to a member function. "

Re: Button fails to activate

Posted: Sat Oct 10, 2009 11:09
by Nomonkeybusiness
Sorry for double-post. It works now. It seemed that an extra '&' had snuck its way into one of the function. A mod can delete the thread.

Re: Button fails to activate

Posted: Sat Oct 10, 2009 11:15
by jacobb
Could it be because your passing a pointer to a subscriber that's going out of scope as soon as the call finishes?