File tree 2 files changed +27
-4
lines changed
2 files changed +27
-4
lines changed Original file line number Diff line number Diff line change @@ -175,14 +175,19 @@ Blockly.svgResize = function(workspace) {
175
175
} ;
176
176
177
177
/**
178
- * Handle a key-down on SVG drawing surface.
178
+ * Handle a key-down on SVG drawing surface. Does nothing if the main workspace is not visible.
179
179
* @param {!Event } e Key down event.
180
180
* @private
181
181
*/
182
+ // TODO (https://github.com/google/blockly/issues/1998) handle cases where there are multiple workspaces
183
+ // and non-main workspaces are able to accept input.
182
184
Blockly . onKeyDown_ = function ( e ) {
183
- if ( Blockly . mainWorkspace . options . readOnly || Blockly . utils . isTargetInput ( e ) ) {
185
+ if ( Blockly . mainWorkspace . options . readOnly || Blockly . utils . isTargetInput ( e )
186
+ || ( Blockly . mainWorkspace . rendered && ! Blockly . mainWorkspace . isVisible ( ) ) ) {
184
187
// No key actions on readonly workspaces.
185
188
// When focused on an HTML text input widget, don't trap any keys.
189
+ // Ignore keypresses on rendered workspaces that have been explicitly
190
+ // hidden.
186
191
return ;
187
192
}
188
193
var deleteBlock = false ;
Original file line number Diff line number Diff line change @@ -127,12 +127,20 @@ Blockly.WorkspaceSvg.prototype.resizeHandlerWrapper_ = null;
127
127
128
128
/**
129
129
* The render status of an SVG workspace.
130
- * Returns `true ` for visible workspaces and `false` for non-visible,
131
- * or headless, workspaces .
130
+ * Returns `false ` for headless workspaces and true for instances of
131
+ * `Blockly.WorkspaceSvg` .
132
132
* @type {boolean }
133
133
*/
134
134
Blockly . WorkspaceSvg . prototype . rendered = true ;
135
135
136
+ /**
137
+ * Whether the workspace is visible. False if the workspace has been hidden
138
+ * by calling `setVisible(false)`.
139
+ * @type {boolean }
140
+ * @private
141
+ */
142
+ Blockly . WorkspaceSvg . prototype . isVisible_ = true ;
143
+
136
144
/**
137
145
* Is this workspace the surface for a flyout?
138
146
* @type {boolean }
@@ -316,6 +324,15 @@ Blockly.WorkspaceSvg.prototype.getInverseScreenCTM = function() {
316
324
return this . inverseScreenCTM_ ;
317
325
} ;
318
326
327
+ /**
328
+ * Getter for isVisible
329
+ * @return {boolean } Whether the workspace is visible. False if the workspace has been hidden
330
+ * by calling `setVisible(false)`.
331
+ */
332
+ Blockly . WorkspaceSvg . prototype . isVisible = function ( ) {
333
+ return this . isVisible_ ;
334
+ } ;
335
+
319
336
/**
320
337
* Mark the inverse screen CTM as dirty.
321
338
*/
@@ -865,6 +882,7 @@ Blockly.WorkspaceSvg.prototype.setVisible = function(isVisible) {
865
882
Blockly . hideChaff ( true ) ;
866
883
Blockly . DropDownDiv . hideWithoutAnimation ( ) ;
867
884
}
885
+ this . isVisible_ = isVisible ;
868
886
} ;
869
887
870
888
/**
You can’t perform that action at this time.
0 commit comments