TargetType and user defined classes

For help with general CEGUI usage:
- Questions about the usage of CEGUI and its features, if not explained in the documentation.
- Problems with the CMAKE configuration or problems occuring during the build process/compilation.
- Errors or unexpected behaviour.

Moderators: CEGUI MVP, CEGUI Team

reacher
Just popping in
Just popping in
Posts: 8
Joined: Thu Apr 02, 2009 14:29

TargetType and user defined classes

Postby reacher » Mon Apr 13, 2009 04:20

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!

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

Postby CrazyEddie » Mon Apr 13, 2009 08:21

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


Return to “Help”

Who is online

Users browsing this forum: Google [Bot] and 14 guests