No keyboard access to quarks during drag.

Same issue as zooming with the mouse wheel.
This commit is contained in:
Neil Fraser
2019-03-28 16:06:20 -07:00
committed by Neil Fraser
parent 6862a7fe70
commit 68e134b073
3 changed files with 21 additions and 10 deletions

View File

@@ -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 &&

View File

@@ -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;
};

View File

@@ -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;