mirror of
https://github.com/google/blockly.git
synced 2026-01-18 06:17:12 +01:00
This commit is contained in:
@@ -65,7 +65,8 @@ Blockly.inject = function(container, opt_options) {
|
||||
var workspace = Blockly.createMainWorkspace_(svg, options, blockDragSurface,
|
||||
workspaceDragSurface);
|
||||
Blockly.init_(workspace);
|
||||
workspace.markFocused();
|
||||
Blockly.mainWorkspace = workspace;
|
||||
|
||||
Blockly.svgResize(workspace);
|
||||
return workspace;
|
||||
};
|
||||
@@ -212,7 +213,7 @@ Blockly.createMainWorkspace_ = function(svg, options, blockDragSurface, workspac
|
||||
|
||||
// A null translation will also apply the correct initial scale.
|
||||
mainWorkspace.translate(0, 0);
|
||||
mainWorkspace.markFocused();
|
||||
Blockly.mainWorkspace = mainWorkspace;
|
||||
|
||||
if (!options.readOnly && !options.hasScrollbars) {
|
||||
var workspaceChanged = function() {
|
||||
|
||||
@@ -1391,7 +1391,15 @@ Blockly.WorkspaceSvg.prototype.setBrowserFocus = function() {
|
||||
// IE and Edge do not support focus on SVG elements. When that fails
|
||||
// above, get the injectionDiv (the workspace's parent) and focus that
|
||||
// instead. This doesn't work in Chrome.
|
||||
this.getParentSvg().parentNode.focus();
|
||||
try {
|
||||
// In IE11, use setActive (which is IE only) so the page doesn't scroll
|
||||
// to the workspace gaining focus.
|
||||
this.getParentSvg().parentNode.setActive();
|
||||
} catch (e) {
|
||||
// setActive support was discontinued in Edge so when that fails, call
|
||||
// focus instead.
|
||||
this.getParentSvg().parentNode.focus();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user