Numeric behavior of editbox

Started by billarhos, 04 November 2015, 15:03:03


Setting numeric values with "1.000,00"  form, the output result is "1.00000". The edit box is in numeric state. Took a look at your code and see that you stop adding special
character after taking the first one.

Is it proper?


The idea of the current code was that you can use either a dot or a comma symbol to use for the decimal point. But things like spaces or more dots or more commas to make the text more readable are not supported.

I am aware that there is currently not enough control on which values are supported. When some people want numeric input they don't want to allow having negative numbers or only want whole numbers. In some cases "-5.26E-4" would be allowed, but when e.g. asking for the width of the window that value makes little sense.

I'm not sure if what you wrote would ever be supported though, because what if you write "1.000"? A lot of people will see that as 1 instead of 1000. It all depends on where you live.

So I will have to add something in the future to allow more options on how the string can look. But right now the only thing you can do to make edit box act like you want is not putting it into numbers only mode and binding the TextChanged signal. In the callback function you would remove unaccepted characters and you have full control over which characters can occur where.