Skip to content

Commit c861728

Browse files
authored
Merge pull request scratchfoundation#4712 from kchadha/extension-button-support
Register callback keys for buttons used in future extensions.
2 parents 0210634 + e82e370 commit c861728

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

src/containers/blocks.jsx

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,21 @@ class Blocks extends React.Component {
9696
);
9797
this.workspace = this.ScratchBlocks.inject(this.blocks, workspaceConfig);
9898

99+
// Register buttons under new callback keys for creating variables,
100+
// lists, and procedures from extensions.
101+
102+
const toolboxWorkspace = this.workspace.getFlyout().getWorkspace();
103+
104+
const varListButtonCallback = type =>
105+
(() => this.ScratchBlocks.Variables.createVariable(this.workspace, null, type));
106+
const procButtonCallback = () => {
107+
this.ScratchBlocks.Procedures.createProcedureDefCallback_(this.workspace);
108+
};
109+
110+
toolboxWorkspace.registerButtonCallback('MAKE_A_VARIABLE', varListButtonCallback(''));
111+
toolboxWorkspace.registerButtonCallback('MAKE_A_LIST', varListButtonCallback('list'));
112+
toolboxWorkspace.registerButtonCallback('MAKE_A_PROCEDURE', procButtonCallback);
113+
99114
// Store the xml of the toolbox that is actually rendered.
100115
// This is used in componentDidUpdate instead of prevProps, because
101116
// the xml can change while e.g. on the costumes tab.

0 commit comments

Comments
 (0)