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
21 changes: 16 additions & 5 deletions core/blockly.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -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) {
Expand All @@ -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);
Expand Down
8 changes: 8 additions & 0 deletions core/workspace_svg.js
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down