ScriptedEvent "AddedChild" not fired during loadWindowLayout

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

marvinx
Just popping in
Just popping in
Posts: 12
Joined: Sat Feb 09, 2013 13:55

ScriptedEvent "AddedChild" not fired during loadWindowLayout

Postby marvinx » Mon Feb 18, 2013 18:35

Hi,

I've written a simple window *.layout which defines a DefaultWindow (used as GUISheet) with two custom child widgets; see the pasted XML code below. For the main window I use two handlers for "AddedChild" and "RemovedChild" events. The problem I've encountered is as follows. When I load this layout (as a part of my Lua main script), then only the "RemovedChild" handler gets called, but --not-- the "AddedChild" event handler. It seems (for me) that during loadWindowLayout() no "AddedChild" events are fired ?!

I need these two events to perform some specific actions after a new child widget was added/removed to/from the main window.

Thanks for any help in advance!

==============================================
<GUILayout>

<Window Type="DefaultWindow" Name="Root">

<!-- Main window properties -->

<Property Name="UnifiedSize" Value="{{1,0},{1,0}}" />
<Property Name="MousePassThroughEnabled" value="True" />

<!-- Import NodeWidget layouts and create child nodes -->

<LayoutImport Filename="SensorNode.layout" Prefix="SNS_1" />
<LayoutImport Filename="SensorNode.layout" Prefix="SNS_2" />
<LayoutImport Filename="ActorNode.layout" Prefix="ACT_1" />

<!-- Scripted Events and handlers -->

<Event Name="AddedChild" Function="OnChildWindow_added" />
<Event Name="RemovedChild" Function="OnChildWindow_removed" />

</Window>

</GUILayout>
=========================================================

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

Re: ScriptedEvent "AddedChild" not fired during loadWindowLa

Postby CrazyEddie » Tue Feb 19, 2013 09:28

The issue here is the order in which the tags are processed. By the time the Event tags are reached - and therefore the event subscriptions made - the imported layouts are already added, thus no events are fired. The worst thing is that this sequence is mandated by the .xsd schema - with hindsight, this is clearly a mistake.

If you're not using xerces-c++ as your XML parser, will never use xerces-c++ as your XML parser and know that none of your target users will ever use xerces-c++ as the XML parser, then you can re-order the elements so that the event subscriptions happen first, and the events should then fire as you expect. If you can't guarantee that xerces-c++ will not be used when loading your files, there is no real fix currently (because xerces-c++ will throw an exception when it detects the tags in the 'wrong' sequence).

I have raised a ticket on our mantis tracker so that this requirement when using xerces-c++ can be relaxed in the future.

CE

marvinx
Just popping in
Just popping in
Posts: 12
Joined: Sat Feb 09, 2013 13:55

Re: ScriptedEvent "AddedChild" not fired during loadWindowLa

Postby marvinx » Tue Feb 19, 2013 11:34

Thanks for this comprehensive answer!! Re-ordering the XML elements in the layout does work for me, since I am using TinyXML parser for all of my projects. So I can go on :D .

User avatar
Kulik
CEGUI Team
Posts: 1382
Joined: Mon Jul 26, 2010 18:47
Location: Czech Republic
Contact:

Re: ScriptedEvent "AddedChild" not fired during loadWindowLa

Postby Kulik » Tue Feb 19, 2013 11:40

just a side note: TinyXML is probably the slowest and most memory hungry choice you can make :)

HTH

marvinx
Just popping in
Just popping in
Posts: 12
Joined: Sat Feb 09, 2013 13:55

Re: ScriptedEvent "AddedChild" not fired during loadWindowLa

Postby marvinx » Tue Feb 19, 2013 12:21

>> TinyXML is probably the slowest and most memory hungry choice you can make

Can you explain that in more detail? It would be interesting to know why TinyXML is not "tiny". What would be a more lightweight alternative? I originally planned to use RapidXML as CEGUI default parser module, but then I chose TinyXML (I can't remember why).

User avatar
Kulik
CEGUI Team
Posts: 1382
Joined: Mon Jul 26, 2010 18:47
Location: Czech Republic
Contact:

Re: ScriptedEvent "AddedChild" not fired during loadWindowLa

Postby Kulik » Tue Feb 19, 2013 13:28


marvinx
Just popping in
Just popping in
Posts: 12
Joined: Sat Feb 09, 2013 13:55

Re: ScriptedEvent "AddedChild" not fired during loadWindowLa

Postby marvinx » Tue Feb 19, 2013 14:20

I think I should eventually switch to CEGUI's RapidXML parser module :roll: Its also interesting to see the poor performance of irrXML in this benchmark, compared to what it's supposed be according to http://www.ambiera.com/irrxml/

Thanks a lot for posting the link!


Return to “Modifications / Integrations / Customisations”

Who is online

Users browsing this forum: No registered users and 5 guests