Skip to main content

Customizing context menus

1. Codelab overview

What you'll learn

In this codelab you will learn how to:

  • Add a context menu option to the workspace.
  • Add a context menu option to all blocks.
  • Use precondition functions to hide or disable context menu options.
  • Take an action when a menu option is selected.
  • Customize ordering and display text for context menu options.

What you'll build

A very simple Blockly workspace with a few new context menu options.

What you'll need

  • A browser.
  • A text editor.
  • Basic knowledge of HTML, CSS, and JavaScript.

This codelab is focused on Blockly's context menus. Non-relevant concepts and code are glossed over and are provided for you to simply copy and paste.