# Events

An event runs an action when something happens to a container. A short action fits on the line;
several actions go one per line underneath.

| Event | Runs when |
|---|---|
| `on_tap` | it is tapped |
| `on_hold` | it is pressed and held |
| `on_touch` | a finger lands on it (at once, with no tap highlight: for games) |
| `on_swipe` | a swipe: `left:`, `right:`, `up:`, `down:` underneath |
| `on_change` | the text of an input changes |
| `on_submit` | Enter / Done is pressed in an input |
| `on_hit` | two containers start to overlap: `a, b: action` underneath (games) |

```vi
taps = 0
last = "nothing yet"

main pad:
  arrange: center
  space_between: 12
  color: green[50]
  on_swipe:
    left: last = "swiped left"
    right: last = "swiped right"
  children:
    target:
      size: 40
      shape: circle
      color: green[700]
      arrange: center
      text: "{taps}"
      text_style: 36, bold, white
      on_tap: taps = taps + 1
      on_hold:
        taps = 0
        last = "held: back to zero"
    log:
      text: "Last: {last}"
```
