- This article or section documents the current version of Scratch (version 3.0). For this article in Scratch 2.0, see Scripts Area.
The Code Area is the area on the left side of the project editor where scripts are assembled. It can be accessed from both the Stage and from sprites, although the Stage and each sprite all have separate Code Areas and scripts. It is a gray pinstriped rectangle.
- Main article: Context Menu
The Code Area menu consists of three options when right-clicked. It can also be brought up by holding down the left mouse, as a feature for one button mouses. The options are:
- Undo: this reverts the last edit.
- Redo: this replaces the last undid edit.
- Clean Up: This feature allows a user to organize oddly placed scripts on the Code Area. Scratch will order them vertically on the left side of the Code Area, with a slight space in between each.
- Add Comment: This was created as a replacement for the comment block in Scratch 1.2. It was removed because it confused users; it has no effect on a sprite's scripts. After much protesting of its removal on the Scratch Website, the current comment feature was introduced in Scratch 1.3. It allows for a user to type notes or helpful comments in a convenient area, usually explaining how their scripts work. The user can also attach it to scripts and adjust its width. Despite all of their help, comments greatly slow a project's speed - they are sometimes avoided or placed detached from their wanted places in their script. The placement of a comment was very buggy in Scratch 2.0: they attached or detached unexpectedly, and sometimes even vanished.
When a user right clicks on a block in the editing area, they get the following options as well as "Add Comment":
- Duplicate: Duplicates the script and allows the user to place it either somewhere else within the sprite or on another sprite.
- Add Comment: Creates a comment, which is attached to the block the user right clicked on.
- Delete Block: Deletes only the selected block. If a stack block containing a script underneath is selected, it shows "Delete _ Blocks" and deletes the entire script.
- Help: This option was only available in Scratch 2.0. It opened the Block Help, which is now in the Project Tutorials.
These options are only available for custom blocks:
- Edit: Opens the custom block edit window.
- Define: This only appears on uses of the custom block. This will scroll the code area to the define block.
Some blocks have other options, these options change the block to a similar block, this applies to:
- +, -, *, /: This will change the block to another operation.
- =, <, >: This will change the block to another operation.
- All variables: A list of variables will show up, when one is clicked, the variable reporter will change to that variable.
- All lists: A list of lists will show up, when one is clicked, the list reporter will change to that list.
To code in Scratch, simply drag blocks out from the eight palettes and assemble them in the Code Area. If necessary, scroll bars will appear to extend the area downwards or to the right. You can also change values of blocks that are in the block palette, but changes back to default when the palette is redrawn. A mouse or touchpad can be used to scroll the code area vertically. A touchpad can also scroll the area horizontally.
Blocks can be removed by dragging the block(s) into the block palette. Another way to delete blocks is to right-click (control-click also works on Macs) and click "delete" in the drop-down menu that appears.