[SOLVED] Custom widget constructor not being invoked

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

daves
Home away from home
Home away from home
Posts: 253
Joined: Thu Feb 02, 2006 20:12

[SOLVED] Custom widget constructor not being invoked

Postby daves » Wed May 23, 2007 17:37

I just tried to set a break point in my custom widget constructor. I'm using the code that levia posted here:

http://www.cegui.org.uk/wiki/index.php/ ... istboxItem

so my constructor looks like this:

Code: Select all

   CEGUI_DEFINE_WINDOW_FACTORY(CheckListboxItem)
   const String CheckListboxItem::WidgetTypeName("CEGUI/CheckListboxItem");
   CheckListboxItem::CheckListboxItem(const String &type, const String &name) :
            ItemEntry(type, name)
   {
      int i = 0;
   }


For some reason I see the ItemEntry constructor being invoked but not that of my custom widget.

at the application level I register the custom factory as follows:

Code: Select all

   CEGUI::WindowFactoryManager& wfMgr = CEGUI::WindowFactoryManager::getSingleton();
    wfMgr.addFactory(&CEGUI_WINDOW_FACTORY(CheckListboxItem));
    wfMgr.addFalagardWindowMapping("WindowsLook/CheckListboxItem", "CEGUI/ItemEntry", "WindowsLook/CheckListboxItem", "Falagard/ItemEntry");


and then instantiate the widget as follows:

Code: Select all

CEGUI::CheckListboxItem * check = (CEGUI::CheckListboxItem*)wmgr.createWindow("WindowsLook/CheckListboxItem", "ckb");


I assumed that the constructor was being invoked because when I run my app I see a box containing a text item with a checkbox to the left of it. I assumed that because I saw the checkbox that the constructor must be called. But I'm thinking now that I see the checkbox next to the list item because of the looknfeel specification of the custom widget.

Why is my constructor not being called in direct response to the "createWindow"?

Edited with the following finding:



Hmm its the following call:

Code: Select all

wfMgr.addFalagardWindowMapping("WindowsLook/CheckListboxItem", "CEGUI/ItemEntry", "WindowsLook/CheckListboxItem", "Falagard/ItemEntry");


If I change it to this

Code: Select all

wfMgr.addFalagardWindowMapping("WindowsLook/CheckListboxItem", "CEGUI/CheckListboxItem", "WindowsLook/CheckListboxItem", "Falagard/ItemEntry");


then my constructor is called. Is one of these two methods wrong, or are they both reasonable depending on the nature of the custom widget?

User avatar
Ludi
Quite a regular
Quite a regular
Posts: 59
Joined: Sun Aug 13, 2006 12:33

Postby Ludi » Wed May 23, 2007 17:57

There's a small mistake in the article.

Have a look at this thread, nearly at the end: http://www.cegui.org.uk/phpBB2/viewtopic.php?t=2571

daves
Home away from home
Home away from home
Posts: 253
Joined: Thu Feb 02, 2006 20:12

Postby daves » Wed May 23, 2007 19:15

Thanks for the pointer. Did you ever work through the other issues that you highlighted within that thread?

User avatar
Ludi
Quite a regular
Quite a regular
Posts: 59
Joined: Sun Aug 13, 2006 12:33

Postby Ludi » Wed May 23, 2007 20:17

What other issue do you mean?


Return to “Help”

Who is online

Users browsing this forum: No registered users and 23 guests