Forum Discussion
Calculator with visible decimal point on screen
Hi. I downloaded David Charney's calculator that he made, and it works great! The only problem is that when you hit the decimal point, the decimal point doesn't appear on the screen until you hit the next number after it. I need for the decimal point to appear in the box as soon as it is clicked. Is this even possible? I am attaching his download, but if anyone else has a solution, I'm all ears. Thanks in advance!
1 Reply
- Nathan_HilliardCommunity Member
If you still need this, it looks like the easiest solution (a general outline) is to add a text variable (currentNumText) that can represent the text version of the displayed calculator value (currentNum), use this text variable for the display instead, and create a JavaScript trigger to update the text variable with the new value anytime the currentNum changes.
In the script, you would need to check if the isDecimal variable is true. If so, check if the currentNum variable is currently a whole number or a decimal. If currentNum is a whole number, convert currentNum to a string and append a decimal to the end. If it is a decimal, or isDecimal is false, just convert it to a string (limited to whatever length is appropriate for the display). Save the final string to currentNumText in Storyline.
The display should now show your modified vaue, with the decimal if appropriate.