mirror of
https://github.com/google/blockly.git
synced 2026-01-10 02:17:09 +01:00
Stop handling keypresses when the workspace is hidden.
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user