File tree Expand file tree Collapse file tree 2 files changed +30
-0
lines changed Expand file tree Collapse file tree 2 files changed +30
-0
lines changed Original file line number Diff line number Diff line change @@ -38,6 +38,7 @@ import { ScratchContinuousToolbox } from "./scratch_continuous_toolbox.js";
38
38
import "./scratch_continuous_category.js" ;
39
39
import "./scratch_comment_icon.js" ;
40
40
import "./scratch_variable_model.js" ;
41
+ import "./scratch_connection_checker.js" ;
41
42
import "./events_block_comment_change.js" ;
42
43
import "./events_block_comment_collapse.js" ;
43
44
import "./events_block_comment_create.js" ;
Original file line number Diff line number Diff line change
1
+ /**
2
+ * @license
3
+ * Copyright 2024 Google LLC
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+
7
+ import * as Blockly from "blockly/core" ;
8
+
9
+ class ScratchConnectionChecker extends Blockly . ConnectionChecker {
10
+ // This check prevents dragging a block into the slot occupied by the
11
+ // procedure caller example block in a procedure definition block.
12
+ doDragChecks ( a , b , distance ) {
13
+ if (
14
+ b . getSourceBlock ( ) . type === "procedures_definition" &&
15
+ b . getParentInput ( ) ?. name === "custom_block"
16
+ ) {
17
+ return false ;
18
+ }
19
+
20
+ return super . doDragChecks ( a , b , distance ) ;
21
+ }
22
+ }
23
+
24
+ Blockly . registry . register (
25
+ Blockly . registry . Type . CONNECTION_CHECKER ,
26
+ Blockly . registry . DEFAULT ,
27
+ ScratchConnectionChecker ,
28
+ true
29
+ ) ;
You can’t perform that action at this time.
0 commit comments