Textfield Control - only set Input Chars

Hi Community,



i’m new to the SDK and trying to limit a input to a set of chars.



like:

“a-z” + “A-Z” + “0-9” + “@” + “.”



i tried to implement it via contoller with:

[java]boolean inputEvent(NiftyInputEvent inputEvent){}

[/java]



but i think its not the proper way to do it.

any suggestions maybe ?



greetings Andreas

Regex:



name.replaceAll("[[^\w\däüöÄÜÖ/±. ]]", "");



the the w does A-Z,a-z and then theres some german special characters to keep as well, slash, plus, minus, dot and space. Everything else is replaced with “_”

Edit: ugh,forum removes backslashes… quote this message to see the real content

This feature was only recently added to Nifty and is not yet released or available for jme. You can find a sneak peek at git hub: https://github.com/void256/nifty-gui/blob/1.3/nifty-controls/src/main/java/de/lessvoid/nifty/controls/TextField.java



What’s missing is a proper documentation in the wiki (http://sourceforge.net/apps/mediawiki/nifty-gui/index.php?title=Standard_Controls_TextField) for it :confused:



If you can’t wait then yes, the inputEvent() method would be the correct way to do it.



Edit: Fixed the link to not refer to the commits but to the current 1.3.2-SNAPSHOT TextField API.

thanks you for the fast replay.



this would be a way. maybe to make clearer what i’m about to do:



the fields is for input of a email address. so the user might think he could enter like mystupidemailaddress$$$@superhost!!().asd

i would like to check the character he types to decide if i add, or not.



i could do a check after each input event, like:



check for input event

check for unwanted character as last input

remove or keep input



i guess this would be the better solution than replacing unwanted ones with something or nothing.



so there is no function to get the input of the user bevor its added to the textfield and gives me the possibility to approve or reject the input ?



greets

so there is no function to get the input of the user bevor its added to the textfield and gives me the possibility to approve or reject the input ?


There is no function like that available to you at the moment but it will be soon :)
@void256 said:
This feature was only recently added to Nifty and is not yet released or available for jme. You can find a sneak peek at git hub: https://github.com/void256/nifty-gui/blob/1.3/nifty-controls/src/main/java/de/lessvoid/nifty/controls/TextField.java

What's missing is a proper documentation in the wiki (http://sourceforge.net/apps/mediawiki/nifty-gui/index.php?title=Standard_Controls_TextField) for it :/

If you can't wait then yes, the inputEvent() method would be the correct way to do it.

Edit: Fixed the link to not refer to the commits but to the current 1.3.2-SNAPSHOT TextField API.


nice :D then i will just wait for public release.
i guess in alpha is no need to implement an work arround for the sake.

thanks for your help :)