A hat block is a block placed at the top of a script to run it once an event was triggered. Top level scripts without hat blocks will never run (unless clicked). Hat blocks cannot be placed inside scripts, with or without rings. In Snap 6.0, there are 6 hat blocks, one only for sprites. All hat blocks are currently in control.

BlockFunctionOptions
when flag clickedTriggers when the green flag is clicked by the user.
when [space V] key pressedTriggers when the key selected is pressed. Thread safe scripts is always on for these scripts. Triggers again for the key repeat interval of the computer. The input is evaluated when any key is pressed.
  • [0-9]
  • any key
  • up arrow
  • down arrow
  • right arrow
  • left arrow
  • space
  • +
  • -
  • [a-z]
when I am [clicked V]Triggers when the action selected is done to the sprite. It will also trigger for the stage if the action is done anywhere. Stopped is triggered when the user clicks the stop sign. It triggers one frame before the scripts are stopped. The input is evaluated when any of the actions are done.
  • clicked
  • pressed
  • dropped
  • mouse-entered
  • mouse-departed
  • scrolled-up
  • scrolled-down
  • stopped
when I receive [ V] @addInputTriggers when a broadcast block is run, and the broadcast input is the same as this input. The input is evaluated when any broadcast block is activated.Any string literal.
when <>Triggers when the input is evaluated to true. The input is evaluated every frame. However, when the stop sign is clicked, all these inputs stop evaluating. They evaluate again when the stop sign is clicked again or the green flag is clicked.Any boolean, usually not literal.
when I start as a cloneTriggers on every clone exactly once, right after it is created. It is only for sprites.

{my block} :: define+

Triggers when a custom block is ran

when [anything V] is edited @addInput

Triggers when anything in the specified sprite is edited. You can get data of what was edited when you click the right arrowhead.
  • anything
  • [sprites]

Hat Blocks in Grey Rings

It is not possible to put hat blocks in grey rings in the editor, but it is possible by editing the project xml. You can find all the hat blocks in grey rings in this project .