diff --git a/js/activity.js b/js/activity.js index 80fe79c855..f1967cd59c 100644 --- a/js/activity.js +++ b/js/activity.js @@ -510,11 +510,11 @@ class Activity { (event) => { event.preventDefault(); event.stopPropagation(); - if (!this.beginnerMode) { - if (event.target.id === "myCanvas") { - this._displayHelpfulWheel(event); - } - } + if (this.beginnerMode) return; + if (!this.blocks.isCoordinateOnBlock(event.clientX, event.clientY) && + event.target.id === "myCanvas") { + this._displayHelpfulWheel(event); + } }, false ); diff --git a/js/blocks.js b/js/blocks.js index 3e97110991..121c0db872 100644 --- a/js/blocks.js +++ b/js/blocks.js @@ -7036,5 +7036,25 @@ class Blocks { this.setSelectedBlocks = (blocks) => { this.selectedBlocks = blocks; }; + + /** + * Checks if coordinates intersect with any block + * @public + * @param {number} x - The x coordinate to check + * @param {number} y - The y coordinate to check + * @returns {boolean} True if coordinates intersect with a block + */ + this.isCoordinateOnBlock = function(x, y) { + return this.blockList.some(block => { + if (block.trash) return false; + + const blockX = block.container.x; + const blockY = block.container.y; + return x >= blockX && + x <= blockX + block.width && + y >= blockY && + y <= blockY + block.height; + }); + }; } }