Page 1 of 1

Recover general events in C/C++

Posted: Fri Nov 11, 2016 14:57
by Brouilles
Hello,
I would like to know if by default CEGUI allows to set up an event system between the C ++ / C code and a .layout ? I have seen in the documentation that it is possible in lua with :

Code: Select all

<Event Name="Clicked" Function="luabtn_clicked" />

Is it possible to retrieve it in C++, whether I can link an event name to an internal function ? Otherwise I thought of setting up an xml mapping with the id of the button and an event next to the layout. But if CEGUI allows it.

In any case, I congratulate the team behind CEGUI for your work !

I apologize for my bad English.
Thank you for your answers,
Best regards.

Re: Recover general events in C/C++

Posted: Fri Nov 11, 2016 16:43
by Ident
As far as I know there is no way to setup callbacks for events for C/C++. I agree though that this is a great feature to have available in our layouts.

Can you elaborate on how you would implement making the link between the callback (that XML knows nothing about) and the event of a widget?

Re: Recover general events in C/C++

Posted: Fri Nov 11, 2016 19:01
by Brouilles
Thank you for your reply.
This is to add an extra xml file next to the layout. This file will store the event linked to a button, via its ID, the event type and an identifier (for a C ++ method) and parameters. I will then set up a class named HandlersCEGUIEvent for example, Interpret the XML document, and create dynamically with CEGUI a subscribe event. On the main lines.

This will make it possible to add events without recompilation on button for example, and will allow modding for my game. I would come back to the subject once I had implemented the system. This is not super clean but will do the trick in my case.

If you have ideas I am also taker of course,
Best regards.

Re: Recover general events in C/C++

Posted: Fri Nov 11, 2016 21:37
by Ident
I dont understand why you dont just add this as an XML child element to the widget in the layout file. Why a new XML file? Referencing widgets via IDs opens up issues becuase you will have to handle the cases where the window isnt there, whereas if you do this in the layout it is inherently guaranteed that the widget exists.

Also I still dont get how you want to get from the "identifier" for a c++ method to its c++ symbol. Mind to show an example XML line for such an event subscription?