Tutorials9 min read

How to Format Currency in Money Transfer App in ProtoPie

Learn how to use the “format()” function to display a number as dollars and cents, pounds and pence, euros, etc.

Jeff Clarke
Jeff Clarke, UX Designer & ProtoPie EducatorJune 29, 2022
How to Format Currency in Money Transfer App Thumbnail

Quick Summary

Transfer Screen Prototype Made With ProtoPie

What You’ll Learn

  • How to use ProtoPie’s built-in format() function
  • How to combine pieces of text together in a formula
  • How to automatically show your device’s native keyboard
  • How to show the numeric keyboard instead of the regular alphabetic one.

Before You Begin

Step-by-Step

Part 1: Set up the input

  • Add an Input layer to your canvas. For now, just position it between the “Transfer amount” layer and the “Continue” button.
    • Leave the layer with its default name Input 1.
    • We’ll make it hidden later, so don’t worry about size, fonts, colors etc.
Add an Input layer to your canvas
the normal alphabetic keyboard
  • With the input field selected on the canvas, scroll to the bottom of the right-hand properties panel to the “Keyboard Options” section.
  • In the “Type” dropdown you can select what keyboard appears when the field is focused. Choose “Number.”
Change the keyboard option to number
numeric keyboard in the preview window
  • Add a Start trigger.
  • The keypad appears when the Input layer is focused. Add a Focus Response under the Start Trigger to the Input 1 layer, and ensure “Focus In” is selected.
Add a Focus trigger to the input layer
  • Uncheck “Tap Return Key
  • Uncheck “Tap outside of Input Layer
Change the focus out options

Part 2: Formatting the input for display

  • Add a Detect Trigger to the Input layer, and set it to detect changes in Input 1's Text property.
Add a Detect Trigger to the Input layer
  • Add a Text Response under the Detect Trigger.
    • Choose the Transfer amount layer.
    • Under Content, choose “Formula
Add a Text Response under the Detect Trigger
  • value - the raw number you wish to format — in our case the user’s typed input
  • format - a pattern representing how you wish to format the number.
  • # to represent whole-number portions of the format
  • 0 to represent decimal portions of the format
  • a decimal character (e.g., . in North America)
  • a separator character (e.g., , as a thousands separator)
  • format(1234.567, "#") will output 1235. No decimal places have been specified in the format, therefore we get only a whole number. Notice how the output is rounded up.
  • format(1234.567, "#,###") will output 1,235. This specifies a separator character, and the three successive # characters mean the separator will be used as a thousands separator.
  • format(1234.567, "#,##") will output 12,35. It is similar to the above except that the separator is followed by 2 successive # characters, and therefore acts as a hundreds separator.
  • format(1234.567, "#,###.00") will output 1,234.57. This ads . as the decimal place character as well as two decimal places. Notice how the output is rounded to the nearest hundredth.
  • format(1234.567, "#.###,00") outputs 1.234,57. This is the same as the above format, however, the . is used as the separator character, and the , is used as the decimal place character. This is a common way to format numbers in Europe and other parts of the world.
  • $1,234.57
  • In the Text Response we just created, use the following formula:
    • "$" + format(Input 1.text, "#,###.00")
Use formula in the Text Response
Check in the preview window
  • "$" + format(Input 1.text / 100, "#,###.00")
Modify the formula
Check in the preview window
Move the input layer outside of the screen
Preview the final effect

Number Formatting... Easy as Pie!

Want more?