Page 1 of 1

EDIT BOX that recieves only numbers?

Posted: Tue Apr 08, 2014 8:11 pm
by KG_is_back
Is it possible to restrict edit box to recieve only numbers as valid data? (like in windows when you enter non-number character it will not get written - instead you get a "ding" sound).

Re: EDIT BOX that recieves only numbers?

Posted: Tue Apr 08, 2014 9:07 pm
by chackl
The easiest way would be to convert the string to the data you loke to have and then Feedback it to the input string of the editbox ;)
Then you neet to "send Trigger only on finish" to true
And adding a Switch to get also input back ;)

I did an short simple example ;)

Regards

Re: EDIT BOX that recieves only numbers?

Posted: Tue Apr 08, 2014 10:01 pm
by Nubeat7
i did one once here: viewtopic.php?f=2&t=1421&start=20
it also has some optimizations in using the edit box

and it has a restrictions module inside, where you can set ruby restrictions, this one takes only numbers everything else is gonna be ignored

but this one is only for int values...

Re: EDIT BOX that recieves only numbers?

Posted: Tue Apr 08, 2014 10:31 pm
by KG_is_back
chackl wrote:The easiest way would be to convert the string to the data you loke to have and then Feedback it to the input string of the editbox Then you neet to "send Trigger only on finish" to trueAnd adding a Switch to get also input back

That's how I'm doing it already. I was more looking for something that would not even allow you to write numbers while editing... It's not really biggie... I'm just trying to make my plugin idiot-proof by not allowing to input random stuff.
Is it possible to make edit box within ruby?

Re: EDIT BOX that recieves only numbers?

Posted: Tue Apr 08, 2014 11:11 pm
by Nubeat7
yes you can make a ruby edit box but i know no way of restriction while typing

here it would just 0.0 if you type wrong..

Re: EDIT BOX that recieves only numbers?

Posted: Tue Apr 08, 2014 11:20 pm
by Nubeat7
here using regex to extract floatingpoint from input string