diff --git a/core/blockly.js b/core/blockly.js index 90ae7568f..e54a8311b 100644 --- a/core/blockly.js +++ b/core/blockly.js @@ -211,7 +211,7 @@ Blockly.onKeyDown_ = function(e) { // data loss. e.preventDefault(); // Don't delete while dragging. Jeez. - if (workspace.isDragging()) { + if (Blockly.Gesture.inProgress()) { return; } if (Blockly.selected && Blockly.selected.isDeletable()) { @@ -219,7 +219,7 @@ Blockly.onKeyDown_ = function(e) { } } else if (e.altKey || e.ctrlKey || e.metaKey) { // Don't use meta keys during drags. - if (workspace.isDragging()) { + if (Blockly.Gesture.inProgress()) { return; } if (Blockly.selected && diff --git a/core/gesture.js b/core/gesture.js index a8e1177e0..736047017 100644 --- a/core/gesture.js +++ b/core/gesture.js @@ -954,3 +954,18 @@ Blockly.Gesture.prototype.getInsertionMarkers = function() { } return []; }; + +/** + * Is a drag or other gesture currently in progress on any workspace? + * @return {boolean} True if gesture is occurring. + */ +Blockly.Gesture.inProgress = function() { + // If a drag is occurring, then it involves a selected block on a workspace. + if (Blockly.selected) { + var currentWorkspace = Blockly.selected.workspace; + if (currentWorkspace && currentWorkspace.currentGesture_) { + return true; + } + } + return false; +}; diff --git a/core/workspace_svg.js b/core/workspace_svg.js index 0a68fe98d..9f9e48829 100644 --- a/core/workspace_svg.js +++ b/core/workspace_svg.js @@ -1302,14 +1302,10 @@ Blockly.WorkspaceSvg.prototype.isMovable = function() { */ Blockly.WorkspaceSvg.prototype.onMouseWheel_ = function(e) { // Don't scroll or zoom anything if drag is in progress. - // If a drag is occurring, then it involves a selected block on a workspace. - if (Blockly.selected) { - var currentWorkspace = Blockly.selected.workspace; - if (currentWorkspace && currentWorkspace.currentGesture_) { - e.preventDefault(); - e.stopPropagation(); - return; - } + if (Blockly.Gesture.inProgress()) { + e.preventDefault(); + e.stopPropagation(); + return; } var canWheelZoom = this.options.zoomOptions && this.options.zoomOptions.wheel; var canWheelMove = this.options.moveOptions && this.options.moveOptions.wheel;