Nifty Gui: Problem creating an User & Password Interface

I have a problem creating a Textfield for the user and password input

It should work with that:









label works

control doesn’t show up



i get no error messages



Hope someone can help!!

I hate that there is no full nifty gui documentation! xD





[java]<!-- +++++++++++++++++++++++++++++++++++++++ →

<!-- MULTIPLAYER →

<!-- +++++++++++++++++++++++++++++++++++++++ →

<screen id=“menu_multiplayer” controller=“gui.controls.SplashController”>

<layer id=“layer” backgroundColor="#0000" childLayout=“center”>

<panel childLayout=“absolute” width=“100%” height=“100%” backgroundColor="#f0ff">

<image id=“image” filename=“gui/texture/ankhel/startmenu/deamon.png” x=“100px” y=“100px”>

<interact onClick=“startTutorial()” />

<effect>

<onStartScreen name=“fade” start="#0" end="#f" length=“500” startDelay=“000”/>

<onEndScreen name=“fade” startColor="#ffff" endColor="#0000" startDelay=“000” length=“500” />

<onHover name=“imageOverlay” filename=“gui/texture/ankhel/startmenu/button.png” post=“false” />

</effect>

</image>

<image id=“image” filename=“gui/texture/ankhel/startmenu/coop.png” x=“100px” y=“160px”>

<interact onClick=“showCoopServer()” />

<effect>

<onStartScreen name=“fade” start="#0" end="#f" length=“500” startDelay=“000”/>

<onEndScreen name=“fade” startColor="#ffff" endColor="#0000" startDelay=“000” length=“500” />

<onHover name=“imageOverlay” filename=“gui/texture/ankhel/startmenu/button.png” post=“false” />

</effect>

</image>

<image id=“image” filename=“gui/texture/ankhel/startmenu/pvp.png” x=“100px” y=“190px”>

<interact onClick=“showPVPServer()” />

<effect>

<onStartScreen name=“fade” start="#0" end="#f" length=“500” startDelay=“000”/>

<onEndScreen name=“fade” startColor="#ffff" endColor="#0000" startDelay=“000” length=“500” />

<onHover name=“imageOverlay” filename=“gui/texture/ankhel/startmenu/button.png” post=“false” />

</effect>

</image>

<image id=“image” filename=“gui/texture/ankhel/startmenu/back.png” x=“100px” y=“270px”>

<interact onClick=“backMainMenu()” />

<effect>

<onStartScreen name=“fade” start="#0" end="#f" length=“500” startDelay=“000”/>

<onEndScreen name=“fade” startColor="#ffff" endColor="#0000" startDelay=“000” length=“500” />

<onHover name=“imageOverlay” filename=“gui/texture/ankhel/startmenu/button.png” post=“false” />

</effect>

</image>

<label id=“label” text=“Username: " width=“150px” x=“400px” y=“100px” textHAlign=“left” style=“menuFont”/>

<control id=“username” width=“150px” name=“textfield” x=“500px” y=“100px”/>

<label id=“label” text=“Password: " width=“150px” x=“400px” y=“120px” textHAlign=“left” style=“menuFont”/>

<control id=“password” width=“150px” name=“textfield” x=“440px” y=“120px” passwordChar=”*”/>



</panel>

</layer>

</screen>[/java]

I’ve just started meddling with Nifty myself, but have you tried defining a “height” for the elements in question? It seems nifty defines the size of the element from its contents, and if you for example set the text contents from inside the app, it doesn’t resize it (at least not if it was empty to begin with).

As i said, i’m just starting out, so i might be wrong.

I tried, but that didn’t solve the problem x(

It seems I don’t understand the concept of “control”

It looks like the element control has to be created within java

You’re not the only one…

I spent well over an hour today before i realized that the reason my gui didn’t show up was because i had an “onHover” in my “control”. It seems it’s really picky about such things.



Controls don’t have to be created from java, though.



I recommend looking through the .xml files that come with the nifty lib. It has one called “allcontrols.xml” and “controls.xml”

Did you include something like:



[xml] <useStyles filename=“nifty-default-styles.xml” />

<useControls filename=“nifty-default-controls.xml” />

[/xml]



in your Nifty XML File so that the controls and the styles are loaded?



I’ve copy’n’pasted your xml snippet into the textfield example of Niftys example project and I can see the textfields o_O



Can you post the whole XML File? Is there anything odd like an exception in the console log?

And yes Nifty is picky. Well to be honest sometimes it’s more than picky, it is bitchy :smiley: and yes, it’s kinda hard to learn especially when you come from a more traditional approach to GUIs. Currently the example projects as well as the wiki are probably the best resources for reference and learning things.



But yeah, I understand the problems (and yes, I can hear the complains ^^) … things will get better tho. Already working on it :slight_smile: