Nifty gui xml editor is eating my code

Hello guys,
I already googled this issue but I couldn’t find any related results.
I’m following the Nifty gui guide from the wiki to implement some screens, but when I switch from the xml editor to the “visual” (using the “Visual” button on top of the xml window) my xml source code gets trimmed and saved without me asking for it. Here’s an example based on the official Nifty-gui samples:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<nifty xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://nifty-gui.lessvoid.com/nifty-gui" xsi:schemaLocation="https://raw.githubusercontent.com/void256/nifty-gui/1.4/nifty-core/src/main/resources/nifty.xsd https://raw.githubusercontent.com/void256/nifty-gui/1.4/nifty-core/src/main/resources/nifty.xsd">
    <useControls filename="nifty-default-controls.xml"/>
    <useStyles filename="nifty-default-styles.xml"/>
    <screen id="start" controller="example.states.StartScreenState" defaultFocusElement="Start">
        <layer id="background" childLayout="center">
        </layer>
        <layer id="foreground" childLayout="vertical">
            <panel id="panel_top" height="25%" width="75%" align="center" childLayout="center">  
                <text text="${CALL.getProgramTitle()}" font="Interface/Fonts/Arial.fnt" width="100%" height="100%" />
            </panel>
            <panel id="panel_mid" height="50%" width="75%" align="center" childLayout="center">       
                <text text="Here goes some text describing the game and the rules and stuff. Incidentally, the text is quite long and needs to wrap at the end of lines. Here goes some text describing the game and the rules and stuff. Incidentally, the text is quite long and needs to wrap at the end of lines. Here goes some text describing the game and the rules and stuff. Incidentally, the text is quite long and needs to wrap at the end of lines." 
              font="Interface/Fonts/Arial.fnt" width="100%" height="100%" wrap="true" />
            </panel>
            <panel id="panel_bottom" height="25%" width="75%" align="center" childLayout="horizontal">  
                <panel id="panel_bottom_left" height="50%" width="50%" valign="center" childLayout="center">  
                    <control name="button" label="Start" id="StartButton" align="center" valign="center" 
                   visibleToMouse="true"> 
                        <interact onClick="startGame(hud)" />
                    </control>
                </panel>
                <panel id="panel_bottom_right" height="50%" width="50%" valign="center" childLayout="center">  
                    <control name="button" label="Quit" id="QuitButton" align="center" valign="center" 
                   visibleToMouse="true" > 
                        <interact onClick="quitGame()"/>
                    </control>
                </panel>
            </panel>
        </layer>
    </screen>
</nifty>

After switching to “Visual” mode and coming back to “Xml” mode my file gets modified without asking and this is the result:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<nifty xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://nifty-gui.lessvoid.com/nifty-gui" xsi:schemaLocation="https://raw.githubusercontent.com/void256/nifty-gui/1.4/nifty-core/src/main/resources/nifty.xsd https://raw.githubusercontent.com/void256/nifty-gui/1.4/nifty-core/src/main/resources/nifty.xsd">
    <useControls filename="nifty-default-controls.xml"/>
    <useStyles filename="nifty-default-styles.xml"/>
    <screen id="start" defaultFocusElement="Start" controller="example.states.StartScreenState">
        <layer id="background" childLayout="center"/>
        <layer id="foreground" childLayout="vertical">
            <panel id="panel_top" childLayout="center" width="75%" align="center" height="25%"/>
            <panel id="panel_mid" childLayout="center" width="75%" align="center" height="50%"/>
            <panel id="panel_bottom" childLayout="horizontal" width="75%" align="center" height="25%">
                <panel id="panel_bottom_left" childLayout="center" width="50%" valign="center" height="50%">
                    <control name="button" id="StartButton" visibleToMouse="true" valign="center" label="Start" align="center"/>
                </panel>
                <panel id="panel_bottom_right" childLayout="center" width="50%" valign="center" height="50%">
                    <control name="button" id="QuitButton" visibleToMouse="true" valign="center" label="Quit" align="center"/>
                </panel>
            </panel>
        </layer>
    </screen>
</nifty>

Is this a feature or a bug? Because many functionalities got cut (like the event handlers for the two buttons) and I can’t undo the modifications. Basically now I’m working with the fear of pushing that evil “Visual” button…

It’s a bug. That editor is not well maintained.

Which version of the SDK are you using? I guess 3.1? 3.0 doesn’t change the XML code at all.

I’m using version 3.1

Well thats in alpha and the nifty editor is as well. I added the newly created nifty editor to master at some point hoping it would accelerate its finalization. Its basically the same code base as this: http://niftyeditor.it