Stop handling keypresses when the workspace is hidden.

This commit is contained in:
Rachel Fenichel
2018-04-23 11:39:38 -07:00
committed by DD
parent e064a147c7
commit 2eeee8b9af
2 changed files with 15 additions and 3 deletions

View File

@@ -173,9 +173,12 @@ Blockly.svgResize = function(workspace) {
* @private
*/
Blockly.onKeyDown_ = function(e) {
if (Blockly.mainWorkspace.options.readOnly || Blockly.utils.isTargetInput(e)) {
if (Blockly.mainWorkspace.options.readOnly || Blockly.utils.isTargetInput(e)
|| (Blockly.mainWorkspace.rendered && !Blockly.mainWorkspace.isVisible)) {
// No key actions on readonly workspaces.
// When focused on an HTML text input widget, don't trap any keys.
// Ignore keypresses on rendered workspaces that have been explicitly
// hidden.
return;
}
var deleteBlock = false;

View File

@@ -131,12 +131,20 @@ Blockly.WorkspaceSvg.prototype.resizeHandlerWrapper_ = null;
/**
* The render status of an SVG workspace.
* Returns `true` for visible workspaces and `false` for non-visible,
* or headless, workspaces.
* Returns `false` for headless workspaces and true for instances of
* `Blockly.WorkspaceSvg`.
* @type {boolean}
*/
Blockly.WorkspaceSvg.prototype.rendered = true;
/**
* Whether the workspace is visible. False if the workspace has been hidden
* by calling `setVisisble(false)`.
* @type {boolean}
* @package
*/
Blockly.WorkspaceSvg.prototype.isVisible = true;
/**
* Is this workspace the surface for a flyout?
* @type {boolean}
@@ -882,6 +890,7 @@ Blockly.WorkspaceSvg.prototype.setVisible = function(isVisible) {
} else {
Blockly.hideChaff(true);
}
this.isVisible = isVisible;
};
/**