PadCodedocs

Actions

Everything your app can do when something happens: every action, by category.

Actions are what your app does when something happens: change a value, open a screen, call an API, show a message. Each view can have steps: actions in a list that run in order when their trigger happens, like When Tapped or When Shown. You set them up in the Inspector's Actions tab, with no code.

For example, a coffee counter's Add a coffee button has one step under When Tapped: a Set Value with State: count and To: ⚡︎ Formula… count + 1. Each tap adds one, and every Text that shows count updates at once. Add a Show Message after it, with Text: Enjoy coffee number {count}, and the app says so at the top for a few seconds.

A button's steps: When Tapped at the top, then each step in order under Do, in order.

Start here:

  • How steps run: build steps in the Actions tab, and what happens when they run, wait or fail.
  • Triggers: every When, and which views offer which.
  • Reusable actions: name a list of steps once and run it from any view.
  • Flow: see a screen's logic as a board, and what each step did in the last Preview.

Every action, by category:

#Data

ActionWhat it does
Set ValueChanges a value in the app's state. Everything that shows it updates.
Flip On/OffTurns a true/false value to the opposite.
Reset ValuePuts a value back to what it started as.
Add to ListAdds an item to a list, like a new note or a new expense.
Update in ListChanges fields of the list items that match a condition.
Remove from ListRemoves the list items that match a condition.
Load FileReads one of this app's own files (Assets → Files) into a variable: a JSON file as its values, a CSV as a list of rows, anything else as text.
ActionWhat it does
Go to ScreenSlides in another screen, with a back button.
Open as SheetShows a screen over the current one: as a sheet that slides up, or full screen.
Go Back / CloseCloses the current sheet, or goes back one screen.
Open LinkOpens a web page in Safari, or a mailto: or tel: link in the app that handles it.
Scroll ToScrolls a Scroll Area until a view is visible.
Focus FieldPuts the cursor in a text field, or hides the keyboard with null.

#Messages & Feedback

ActionWhat it does
Show AlertShows an alert or a dialog with buttons. Each button can run its own steps.
Show MessageShows a short message at the top that goes away by itself.
Play HapticA tap you can feel. iPads without haptics, and most don't have them, skip it; an Apple Pencil Pro plays it.
Play SoundPlays one of PadCode's built-in sounds.
Speak TextReads text out loud.
AnimateRuns steps with animation, so whatever they change moves smoothly instead of jumping.

#Logic

ActionWhat it does
IfRuns some steps only when a condition is true, and others when it's not.
Repeat for EachRuns steps once for every item in a list. Inside, it is the current item.
WaitPauses before the next step.
Run ActionRuns a named action from the app's actions, so the same steps can be reused.
TryRuns steps that might fail, like an API call, and catches the failure instead of stopping. In catch, error.message says what went wrong.
StopStops here; the steps after this one don't run.
Start TimerRuns steps over and over, every so many seconds, until it's stopped.
Stop TimerStops a timer started with Start Timer.
LogWrites a value to Preview's debugger, to check what's going on. People using the app don't see it.

#Web & APIs

ActionWhat it does
Call APISends a request to a web API and saves the answer. JSON answers become values formulas can read: forecast.current.temperature.

#Device

ActionWhat it does
Pick PhotosOpens the photo library so the person can choose photos.
Take PhotoOpens the camera to take a photo.
Scan CodeOpens the camera to read a QR code, a barcode or printed text.
Pick FileOpens Files so the person can choose a file.
Save FileSaves text, JSON or a CSV table to Files.
ShareOpens the share sheet to send text, a link or a photo to another app or person.
CopyCopies text to the clipboard.
Refresh WidgetDraws the widget again with fresh data: its When Shown steps run again, like a Call API. On a widget's button, a tap refreshes that widget; in an app, the app's widgets on the Home Screen.
Get LocationFinds where the iPad is right now.
Face ID / Touch IDAsks the person to prove it's them before continuing. Fails if they cancel.
Schedule NotificationShows a notification later, even when the app is closed.
Cancel NotificationCancels a scheduled notification.
Add to CalendarOpens a filled-in calendar event for the person to check and save.
Write EmailOpens a filled-in email for the person to check and send.

#Apple Intelligence

ActionWhat it does
Ask Apple IntelligenceAsks the on-device model a question and saves the answer: summarize, rewrite, suggest. Private, free, and works offline.