Hopson97 / open-builder

Open "Minecraft-like" game with multiplayer support and Lua scripting support for the both client and server
https://github.com/Hopson97/open-builder/projects/3
GNU General Public License v3.0
700 stars 80 forks source link

Add function to GUI textbox API to limit which characters can be added to it #180

Closed Hopson97 closed 4 years ago

Hopson97 commented 4 years ago

Describe your suggestion

Right now you can type most characters into a text box, but this is not always the wanted behavior.

For example, some text boxes would need only numerical inputs.

Implementations ideas [optional]

Function added to text box widget class that allows this kind of API from the Lua:

textBox:limitChars("123456789"); to limit the input to numbers 1 to 9. Not sure if that is the most clear, so very open to ideas here.

And then add the function to the Lua API in the gui_widget_api.cpp file