Page 1 of 1

TargetType and user defined classes

Posted: Mon Apr 13, 2009 04:20
by reacher
How difficult is it to derive my own custom classes off of CEGUI's classes and link them in a scheme file? I'm looking to add new functionality to the CEGUI::Editbox to not have Tab fire EventTextAccepted. I know I could just derive a class off of Editbox and maybe accomplish this, but how would I specify my own class in the FalagardMapping element in the scheme file? Is what I want to do even possible?

Thanks!

Posted: Mon Apr 13, 2009 08:21
by CrazyEddie
Hi,

Adding your own window types to CEGUI is reasonably simple, though is admittedly more complex that it ought to be in the current releases. Exactly what you'll do and how you'll do it will depend upon the specific version you have, though I'll assume you're using the latest stable.

The general approach is detailed in this post: http://www.cegui.org.uk/phpBB2/viewtopi ... 4730#14730 just ignore anything not specifically related to adding the new type, although since writing that a couple of things have changed to make things a little easier (though the approach in that post is still valid, also).

Basically you need two things; first the Window based class itself (obviously this also includes subclasses of existing window based classes such as Editbox) and second, a WindowFactory based class that creates and destroys instances of the window type.

Then to register your new factory with the system you do:

Code: Select all

CEGUI::WindowFactoryManager::getSingleton().addFactory<MyNewEditboxFactory>();

Note that unlike in the post linked above, this allows you to register the type without needing to create the factory instance yourself.

As a heads-up, we are making this process even simpler for forthcoming releases; we are removing the requirement to manually define factory classes, and registering your new window type will just involve defining the new class and a single line of C++ to register it with the system.

HTH

CE