diff --git a/core/blockly.js b/core/blockly.js index bb1fa9759..427d45199 100644 --- a/core/blockly.js +++ b/core/blockly.js @@ -202,12 +202,16 @@ Blockly.onKeyDown_ = function(e) { } if (Blockly.selected && Blockly.selected.isDeletable() && Blockly.selected.isMovable()) { + // Don't allow copying immovable or undeletable blocks. The next step + // would be to paste, which would create additional undeletable/immovable + // blocks on the workspace. if (e.keyCode == 67) { // 'c' for copy. Blockly.hideChaff(); Blockly.copy_(Blockly.selected); - } else if (e.keyCode == 88) { - // 'x' for cut. + } else if (e.keyCode == 88 && !Blockly.selected.workspace.isFlyout) { + // 'x' for cut, but not in a flyout. + // Don't even copy the selected item in the flyout. Blockly.copy_(Blockly.selected); deleteBlock = true; } @@ -216,7 +220,13 @@ Blockly.onKeyDown_ = function(e) { // 'v' for paste. if (Blockly.clipboardXml_) { Blockly.Events.setGroup(true); - Blockly.clipboardSource_.paste(Blockly.clipboardXml_); + // Pasting always pastes to the main workspace, even if the copy started + // in a flyout workspace. + var workspace = Blockly.clipboardSource_; + if (workspace.isFlyout) { + workspace = workspace.targetWorkspace; + } + workspace.paste(Blockly.clipboardXml_); Blockly.Events.setGroup(false); } } else if (e.keyCode == 90) { @@ -225,8 +235,9 @@ Blockly.onKeyDown_ = function(e) { Blockly.mainWorkspace.undo(e.shiftKey); } } - if (deleteBlock) { - // Common code for delete and cut. + // Common code for delete and cut. + // Don't delete in the flyout. + if (deleteBlock && !Blockly.selected.workspace.isFlyout) { Blockly.Events.setGroup(true); Blockly.hideChaff(); Blockly.selected.dispose(/* heal */ true, true); diff --git a/core/workspace_svg.js b/core/workspace_svg.js index 9a05cc77d..167549359 100644 --- a/core/workspace_svg.js +++ b/core/workspace_svg.js @@ -267,6 +267,14 @@ Blockly.WorkspaceSvg.prototype.flyoutButtonCallbacks_ = {}; */ Blockly.WorkspaceSvg.prototype.toolboxCategoryCallbacks_ = {}; +/** + * In a flyout, the target workspace where blocks should be placed after a drag. + * Otherwise null. + * @type {?Blockly.WorkspaceSvg} + * @package + */ +Blockly.WorkspaceSvg.prototype.targetWorkspace = null; + /** * Inverted screen CTM, for use in mouseToSvg. * @type {SVGMatrix}