Hello!
Is there a way to move the decimal point 2 numbers over in a textfield?
Thanks for the help!
Hello!
Is there a way to move the decimal point 2 numbers over in a textfield?
Thanks for the help!
You could try to search for the number in the string and convert it into an integer.
Than multiply it with 100 und reinsert it in the string.
I’m confused because an integer is a whole number. For example I want to save the user from having to use a decimal character because I’m planning on using the numbers/ or phone keypad layout and decimals can’t be used.
An example: If you want to input 12.34
when you input 1, it will show .01
when you then input 2, it will show .12
when you then input 3, it will show 1.23
when you then input 4, it will show 12.34
Take the contents of the textfield, multiply it by 0.01, and re-update the textfield with the answer.
EG:
1234 * 0.01 = 12.34
Is that what you mean?
Well the native.newInputText deals with strings not numbers, so you will end up with a string of “13049.39”. Once Lua gets ahold of it, it will then work like a number if you try to do math with it. If you’re trying to do something where they enter:
0.01
0.13
1.30
13.04
130.49
type thing, then each time you get an edit phase parse the dot out, then substring off the first bits and last 2 characters and concatenate the dot back in.
You could try to search for the number in the string and convert it into an integer.
Than multiply it with 100 und reinsert it in the string.
I’m confused because an integer is a whole number. For example I want to save the user from having to use a decimal character because I’m planning on using the numbers/ or phone keypad layout and decimals can’t be used.
An example: If you want to input 12.34
when you input 1, it will show .01
when you then input 2, it will show .12
when you then input 3, it will show 1.23
when you then input 4, it will show 12.34
Take the contents of the textfield, multiply it by 0.01, and re-update the textfield with the answer.
EG:
1234 * 0.01 = 12.34
Is that what you mean?
Well the native.newInputText deals with strings not numbers, so you will end up with a string of “13049.39”. Once Lua gets ahold of it, it will then work like a number if you try to do math with it. If you’re trying to do something where they enter:
0.01
0.13
1.30
13.04
130.49
type thing, then each time you get an edit phase parse the dot out, then substring off the first bits and last 2 characters and concatenate the dot back in.