From 94007283fdc24133d9965bbc18e40e9681ab83d8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jens=20M=C3=B6nig?= Date: Sat, 22 Jan 2022 00:21:09 +0100 Subject: [PATCH] support dragging blocks out from result bubbles --- HISTORY.md | 4 ++++ snap.html | 2 +- src/blocks.js | 22 +++++++++++++++++++++- 3 files changed, 26 insertions(+), 2 deletions(-) diff --git a/HISTORY.md b/HISTORY.md index 8520a2dc..51fcf95a 100755 --- a/HISTORY.md +++ b/HISTORY.md @@ -3,12 +3,16 @@ ## in development: * **New Features:** + * support dragging blocks out from result bubbles * **Notable Changes:** * **Notable Fixes:** * fixed layout for scrolling custom categories, thanks, Eckart, for the bug report! * **Documentation Updates:** * **Translation Updates:** +### 2022-01-22 +* blocks: support dragging blocks out from result bubbles + ### 2022-01-21 * new dev version * gui: fixed layout for scrolling custom categories, thanks, Eckart, for the bug report! diff --git a/snap.html b/snap.html index 901a55c5..87812ee4 100755 --- a/snap.html +++ b/snap.html @@ -16,7 +16,7 @@ - + diff --git a/src/blocks.js b/src/blocks.js index da516a54..e33b3d49 100644 --- a/src/blocks.js +++ b/src/blocks.js @@ -160,7 +160,7 @@ CustomCommandBlockMorph, ToggleButtonMorph, DialMorph, SnapExtensions*/ // Global stuff //////////////////////////////////////////////////////// -modules.blocks = '2022-January-07'; +modules.blocks = '2022-January-22'; var SyntaxElementMorph; var BlockMorph; @@ -2259,6 +2259,26 @@ SyntaxElementMorph.prototype.showBubble = function (value, exportPic, target) { morphToShow.bounds.setWidth(img.width); morphToShow.bounds.setHeight(img.height); morphToShow.cachedImage = img; + + // support blocks to be dragged out of result bubbles: + morphToShow.isDraggable = true; + + morphToShow.selectForEdit = function () { + var script = value.toBlock(), + prepare = script.prepareToBeGrabbed; + + script.prepareToBeGrabbed = function (hand) { + prepare.call(this, hand); + hand.grabOrigin = { + origin: ide.palette, + position: ide.palette.center() + }; + this.prepareToBeGrabbed = prepare; + }; + + script.setPosition(this.position()); + return script; + }; } else if (typeof value === 'boolean') { morphToShow = SpriteMorph.prototype.booleanMorph.call( null,