Quick Links: Download Gideros Studio | Gideros Documentation | Gideros community chat | DONATE
how to allow input of negative numbers along with positive numbers (but nothing else) — Gideros Forum

how to allow input of negative numbers along with positive numbers (but nothing else)

i'm using TextInputDialog restricted to numbers
http://wiki.gideros.rocks/index.php/TextInputDialog.NUMBER
but now i want the user to be able also to input negative numbers. is there a way?
or at least if i set the input type to TEXT then to restrict what is allowed to only numbers and "-"? (see https://www.b4x.com/android/forum/threads/entering-negative-numbers.11407/ )

Likes: MoKaLux

+1 -1 (+1 / -0 )Share on Facebook

Comments

  • piepie Member
    I did it once, I used
    textInputDialog:setInputType(TextInputDialog.PHONE)
  • @pie close, but i think it also has some additional not needed characters so it would be nice somehow to restrict that when those are pressed then nothing is written.
  • piepie Member
    I think that I was sanitizing the string afterwards, but another option might be to add a "+/-" button near your inputText that switches the sign.
    If you make use of embedded keyboards I don't think you can change their layout, since they are native android/ios (and on laptop you always have the option to add unexpected chars, so you would always need to sanitize).
    On imgui you can sanitize on the run if I am not mistaken (if I recall there is an inputtext callback on text update), but you are still bound to the native keyboards layouts and chars. Another option might be to draw your own keyboard as nicke did years ago in his layout system.

    Likes: MoKaLux

    +1 -1 (+1 / -0 )Share on Facebook
  • thanks @pie , yes, i added a sanity check like "if tonumber(value) ~= nil then". also a manual keyboard with imgui would do even better but it is not that important that i want to invest that much time. thanks
Sign In or Register to comment.