Subscribing to events

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
wingdongdoodle
Just popping in
Just popping in
Posts: 15
Joined: Tue Mar 15, 2005 21:41

Subscribing to events

Postby wingdongdoodle » Thu Mar 17, 2005 09:13

hello, im back again, this time with a question about subscribing to events. Currently im attempting to create a console class object. Im having trouble subscribing to an editbox event. heres my code:

Code: Select all

class CConsole{
public:
   CConsole();
   void load(std::string filename, CEGUI::WindowManager *wManager);
   void show(bool s);
   void hide();
   void show();
   void toggle();
   void clear();
   void addOutput(const char *fmt, ...);
   bool eventHandler(const CEGUI::EventArgs& e);

private:
   CEGUI::WindowManager *mWindowManager;
   CEGUI::Window *mParentWindow;
   CEGUI::FrameWindow *mFrame;
   CEGUI::Listbox *mOutputList;
   CEGUI::Editbox *mInput;
   int mMaxItems;
   bool mVisible;
};




this appears to be the offending code:

Code: Select all

CConsole::mInput->subscribeEvent(Editbox::EventTextAccepted,&CConsole::eventHandler);



heres the error i get:

term does not evaluate to function taking 1 arguments

an error is pulled up at this code spot:

Code: Select all

/* This class binds a copy of a functor. */
template <class Functor, typename Ret, typename Args>
class _functorBinder : public SubscriberInterface<Ret,Args>
{
public:
  virtual Ret operator()(Args args) const
  {
    return d_f(args);
  }
  _functorBinder(const Functor& f) : d_f(f) {}
protected:
  Functor d_f;
};
.


any ideas? im sure its something i have done, but im not sure what to do next

Guest

Re: Subscribing to events

Postby Guest » Thu Mar 17, 2005 09:43

The second parameter of subscribeEvent() must be an Event::Subscriber, not a function.

Try to use this code instead :
CConsole::mInput->subscribeEvent(Editbox::EventTextAccepted,CEGUI::Event::Subscriber(&CConsole::eventHandler,this));

Hope it helps.

--
Chris

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

Re: Subscribing to events

Postby CrazyEddie » Thu Mar 17, 2005 19:45

ChrisKang is correct: member functions must be bound via CEGUI::Event::Subscriber. Only free functions and functor classes can be specified using your original code.

CE.


Return to “Modifications / Integrations / Customisations”

Who is online

Users browsing this forum: No registered users and 6 guests