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>
=========================================================
ScriptedEvent "AddedChild" not fired during loadWindowLayout
Moderators: CEGUI MVP, CEGUI Team
- CrazyEddie
- CEGUI Project Lead
- Posts: 6760
- Joined: Wed Jan 12, 2005 12:06
- Location: England
- Contact:
Re: ScriptedEvent "AddedChild" not fired during loadWindowLa
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
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
Useful Links: Forum Guidelines | Documentation | Tutorials | HOWTO | Videos | Donate to CEGUI | CEGUI Twitter
Re: ScriptedEvent "AddedChild" not fired during loadWindowLa
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 .
Re: ScriptedEvent "AddedChild" not fired during loadWindowLa
just a side note: TinyXML is probably the slowest and most memory hungry choice you can make
HTH
HTH
Re: ScriptedEvent "AddedChild" not fired during loadWindowLa
>> 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).
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).
Re: ScriptedEvent "AddedChild" not fired during loadWindowLa
I think I should eventually switch to CEGUI's RapidXML parser module 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!
Thanks a lot for posting the link!
Return to “Modifications / Integrations / Customisations”
Who is online
Users browsing this forum: Bing [Bot] and 11 guests