From e82e370e83483055b19d23f298fc86a1ac311128 Mon Sep 17 00:00:00 2001 From: Karishma Chadha Date: Wed, 3 Apr 2019 11:10:10 -0400 Subject: [PATCH] Register callback keys for buttons used in future extensions. --- src/containers/blocks.jsx | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/containers/blocks.jsx b/src/containers/blocks.jsx index ecb998ea4..d79c7e9c7 100644 --- a/src/containers/blocks.jsx +++ b/src/containers/blocks.jsx @@ -96,6 +96,21 @@ class Blocks extends React.Component { ); this.workspace = this.ScratchBlocks.inject(this.blocks, workspaceConfig); + // Register buttons under new callback keys for creating variables, + // lists, and procedures from extensions. + + const toolboxWorkspace = this.workspace.getFlyout().getWorkspace(); + + const varListButtonCallback = type => + (() => this.ScratchBlocks.Variables.createVariable(this.workspace, null, type)); + const procButtonCallback = () => { + this.ScratchBlocks.Procedures.createProcedureDefCallback_(this.workspace); + }; + + toolboxWorkspace.registerButtonCallback('MAKE_A_VARIABLE', varListButtonCallback('')); + toolboxWorkspace.registerButtonCallback('MAKE_A_LIST', varListButtonCallback('list')); + toolboxWorkspace.registerButtonCallback('MAKE_A_PROCEDURE', procButtonCallback); + // Store the xml of the toolbox that is actually rendered. // This is used in componentDidUpdate instead of prevProps, because // the xml can change while e.g. on the costumes tab.