Error when using "subscribeEvent()"

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
Lucky_Luciano
Just popping in
Just popping in
Posts: 6
Joined: Tue Mar 08, 2005 14:39

Error when using "subscribeEvent()"

Postby Lucky_Luciano » Tue Mar 08, 2005 15:45

Hi,

I'm playing around with CEGUI these days and I already used CEGUI in another test-program without a problem but now I've encountered this problem:
Is use this piece of code in my createScene() method in an Ogre3D application:

Code: Select all

CEGUI::WindowManager& wmgr = CEGUI::WindowManager::getSingleton();
        wmgr.getWindow((CEGUI::utf8*)"QuitButton")
         ->subscribeEvent(CEGUI::PushButton::EventClicked,
CEGUI::Event::Subscriber(&ActionBar::handleQuit, this));

and I get this error when compiling the program:

Code: Select all

d:\Ogre\ogrenew\Samples\MapEditor\MapEditor.cpp(62):
error C2661: 'CEGUI::SubscriberTemplate<Ret,Args>::__ctor' :
 no overloaded function takes 2 arguments
        with
        [
            Ret=bool,
            Args=const CEGUI::EventArgs &
        ]
        and
        [
            Ret=bool,
            Args=const CEGUI::EventArgs &
        ]



Very wierd, cause I used the exact line of code in another program before (also in the createScene method).
I fear I don't have enough experience with CEGUI to know what's going on, hence the question :)

Thanks in advance!

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

Re: Error when using "subscribeEvent()"

Postby CrazyEddie » Tue Mar 08, 2005 20:08

Hi,

What's the full prototype / siganture for the ActionBar::handleQuit method?

CE.

User avatar
Lucky_Luciano
Just popping in
Just popping in
Posts: 6
Joined: Tue Mar 08, 2005 14:39

Re: Error when using "subscribeEvent()"

Postby Lucky_Luciano » Tue Mar 08, 2005 21:00

CrazyEddie wrote:
Hi,

What's the full prototype / siganture for the ActionBar::handleQuit method?

CE.

This is the class ActionBar:

Code: Select all

class ActionBar
{
private:
protected:
   CEGUI::Window*   mWindow;
public:
         ActionBar();
         ~ActionBar();
   CEGUI::Window*   getWindow() { return mWindow; }
   bool      handleQuit(const CEGUI::EventArgs& e);
};

This is the implementation of handleQuit

Code: Select all

bool ActionBar::handleQuit(const CEGUI::EventArgs& e)
{
return true;
}

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

Re: Error when using "subscribeEvent()"

Postby CrazyEddie » Wed Mar 09, 2005 10:44

Is your createScene method mentioned in the original post a member of the ActionBar class? It doesn't have to be, but what you do need to ensure is that you're passing a corrent object pointer.

[code]
CEGUI::Event::Subscriber(&ActionBar::handleQuit, this);[/quote]

The 'this' whithin the above construct needs to be an instance of the class which contains the bound member. If you have no instance of the object at this point, then either a free function, or a static member function will need to be used.

HTH

CE.

User avatar
Lucky_Luciano
Just popping in
Just popping in
Posts: 6
Joined: Tue Mar 08, 2005 14:39

Re: Error when using "subscribeEvent()"

Postby Lucky_Luciano » Wed Mar 09, 2005 12:42

Great, I found what I did wrong.
Apparantly I miss-understood the function: I thought the "this" stood for an instance where the function createScene() is declared :)
I replaced "this" with an instance of ActionBar and everything works perfect now.

Thanks for the help Eddie!


Return to “Modifications / Integrations / Customisations”

Who is online

Users browsing this forum: No registered users and 4 guests