forked from scratchfoundation/scratch-blocks
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: prevent dragging blocks into the slot occupied by the procedure …
…definition block's example caller block (scratchfoundation#118) * fix: prevent replacing the procedure definition block's example caller block * chore: remove errant logging
- Loading branch information
Showing
2 changed files
with
30 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
/** | ||
* @license | ||
* Copyright 2024 Google LLC | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
import * as Blockly from "blockly/core"; | ||
|
||
class ScratchConnectionChecker extends Blockly.ConnectionChecker { | ||
// This check prevents dragging a block into the slot occupied by the | ||
// procedure caller example block in a procedure definition block. | ||
doDragChecks(a, b, distance) { | ||
if ( | ||
b.getSourceBlock().type === "procedures_definition" && | ||
b.getParentInput()?.name === "custom_block" | ||
) { | ||
return false; | ||
} | ||
|
||
return super.doDragChecks(a, b, distance); | ||
} | ||
} | ||
|
||
Blockly.registry.register( | ||
Blockly.registry.Type.CONNECTION_CHECKER, | ||
Blockly.registry.DEFAULT, | ||
ScratchConnectionChecker, | ||
true | ||
); |