Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 0 additions & 25 deletions core/blockly.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ goog.require('Blockly.inputTypes');
goog.require('Blockly.internalConstants');
/** @suppress {extraRequire} */
goog.require('Blockly.Procedures');
goog.require('Blockly.ShortcutRegistry');
/** @suppress {extraRequire} */
goog.require('Blockly.Touch');
goog.require('Blockly.utils');
Expand Down Expand Up @@ -148,30 +147,6 @@ Blockly.svgResize = function(workspace) {
mainWorkspace.resize();
};

/**
* Handle a key-down on SVG drawing surface. Does nothing if the main workspace
* is not visible.
* @param {!KeyboardEvent} e Key down event.
* @package
*/
// TODO (https://github.com/google/blockly/issues/1998) handle cases where there
// are multiple workspaces and non-main workspaces are able to accept input.
Blockly.onKeyDown = function(e) {
var mainWorkspace = Blockly.common.getMainWorkspace();
if (!mainWorkspace) {
return;
}

if (Blockly.utils.isTargetInput(e) ||
(mainWorkspace.rendered && !mainWorkspace.isVisible())) {
// When focused on an HTML text input widget, don't trap any keys.
// Ignore keypresses on rendered workspaces that have been explicitly
// hidden.
return;
}
Blockly.ShortcutRegistry.registry.onKeyDown(mainWorkspace, e);
};

/**
* Delete the given block.
* @param {!Blockly.BlockSvg} selected The block to delete.
Expand Down
26 changes: 25 additions & 1 deletion core/inject.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ const Options = goog.require('Blockly.Options');
const ScrollbarPair = goog.require('Blockly.ScrollbarPair');
const Touch = goog.require('Blockly.Touch');
const Tooltip = goog.require('Blockly.Tooltip');
const ShortcutRegistry = goog.require('Blockly.ShortcutRegistry');
const Svg = goog.require('Blockly.utils.Svg');
const Workspace = goog.require('Blockly.Workspace');
const WorkspaceDragSurfaceSvg = goog.require('Blockly.WorkspaceDragSurfaceSvg');
Expand Down Expand Up @@ -263,6 +264,29 @@ const init = function(mainWorkspace) {
}
};

/**
* Handle a key-down on SVG drawing surface. Does nothing if the main workspace
* is not visible.
* @param {!KeyboardEvent} e Key down event.
*/
// TODO (https://github.com/google/blockly/issues/1998) handle cases where there
// are multiple workspaces and non-main workspaces are able to accept input.
const onKeyDown = function(e) {
const mainWorkspace = common.getMainWorkspace();
if (!mainWorkspace) {
return;
}

if (utils.isTargetInput(e) ||
(mainWorkspace.rendered && !mainWorkspace.isVisible())) {
// When focused on an HTML text input widget, don't trap any keys.
// Ignore keypresses on rendered workspaces that have been explicitly
// hidden.
return;
}
ShortcutRegistry.registry.onKeyDown(mainWorkspace, e);
};

/**
* Whether event handlers have been bound. Document event handlers will only
* be bound once, even if Blockly is destroyed and reinjected.
Expand Down Expand Up @@ -290,7 +314,7 @@ const bindDocumentEvents = function() {
}
}
});
browserEvents.conditionalBind(document, 'keydown', null, Blockly.onKeyDown);
browserEvents.conditionalBind(document, 'keydown', null, onKeyDown);
// longStop needs to run to stop the context menu from showing up. It
// should run regardless of what other touch event handlers have run.
browserEvents.bind(document, 'touchend', null, Touch.longStop);
Expand Down
4 changes: 2 additions & 2 deletions tests/deps.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading