From a85ea32b2503f09f1333359392e90f5557c0f17c Mon Sep 17 00:00:00 2001 From: jmoenig Date: Tue, 9 Nov 2021 17:39:32 +0100 Subject: [PATCH] allow block-instances to be dragged off from templates in the "export blocks" dialog --- HISTORY.md | 2 ++ snap.html | 4 ++-- src/blocks.js | 11 ++++++++--- src/byob.js | 12 ++++++------ src/gui.js | 3 ++- 5 files changed, 20 insertions(+), 12 deletions(-) diff --git a/HISTORY.md b/HISTORY.md index 3b0a14a4..13167adc 100755 --- a/HISTORY.md +++ b/HISTORY.md @@ -24,6 +24,7 @@ * migrated SEND blocks to be BROADCAST TO blocks * "when I receive 'any message'" hat scripts are threadsafe (uninterruptable by other messages) * changed the color model for pen/background colors from HSV to HSL + * allow block-instances to be dragged off from templates in the "export blocks" and "hide blocks" dialogs * new Birdbrain Technology extensions for Finch and Hummingbird, thanks, Kristina and Bambi! * retired Leap Motion library * display blocks with their error messages for custom blocks, thanks, Michael! @@ -56,6 +57,7 @@ * gui: adjusted random color for new sprites to HSL model * objects: fixed keyboard entry for script variable getters * gui: changed edit project notes to always edit project motes instead of scene notes +* byob, blocks, gui: allow block-instances to be dragged off from templates in the "export blocks" dialog ### 2021-11-08 * objects: renamed some internal color methods diff --git a/snap.html b/snap.html index 8b8a1195..73cb3bb7 100755 --- a/snap.html +++ b/snap.html @@ -16,14 +16,14 @@ - + - + diff --git a/src/blocks.js b/src/blocks.js index 5f93a551..e2953518 100644 --- a/src/blocks.js +++ b/src/blocks.js @@ -160,7 +160,7 @@ CustomCommandBlockMorph, ToggleButtonMorph, DialMorph, SnapExtensions*/ // Global stuff //////////////////////////////////////////////////////// -modules.blocks = '2021-November-08'; +modules.blocks = '2021-November-09'; var SyntaxElementMorph; var BlockMorph; @@ -2623,8 +2623,13 @@ BlockMorph.prototype.scriptTarget = function () { return ide.currentSprite; } dlg = this.parentThatIsA(DialogBoxMorph); - if (dlg && isSnapObject(dlg.target)){ - return dlg.target; + if (dlg) { + if (isSnapObject(dlg.target)) { + return dlg.target; + } + if (dlg.target instanceof IDE_Morph) { + return dlg.target.currentSprite; + } } throw new Error('script target cannot be found for orphaned block'); }; diff --git a/src/byob.js b/src/byob.js index f042fee7..3b658413 100644 --- a/src/byob.js +++ b/src/byob.js @@ -110,7 +110,7 @@ WatcherMorph, XML_Serializer, SnapTranslator, SnapExtensions*/ // Global stuff //////////////////////////////////////////////////////// -modules.byob = '2021-November-07'; +modules.byob = '2021-November-09'; // Declarations @@ -4140,11 +4140,11 @@ BlockExportDialogMorph.prototype.key = 'blockExport'; // BlockExportDialogMorph instance creation: -function BlockExportDialogMorph(serializer, blocks) { - this.init(serializer, blocks); +function BlockExportDialogMorph(serializer, blocks, target) { + this.init(serializer, blocks, target); } -BlockExportDialogMorph.prototype.init = function (serializer, blocks) { +BlockExportDialogMorph.prototype.init = function (serializer, blocks, target) { // additional properties: this.serializer = serializer; this.blocks = blocks.slice(0); @@ -4153,7 +4153,7 @@ BlockExportDialogMorph.prototype.init = function (serializer, blocks) { // initialize inherited properties: BlockExportDialogMorph.uber.init.call( this, - null, // target + target, // target () => this.exportBlocks(), null // environment ); @@ -4208,7 +4208,7 @@ BlockExportDialogMorph.prototype.buildContents = function () { () => contains(this.blocks, definition), null, null, - block.fullImage() + this.target ? block : block.fullImage() ); checkBox.setPosition(new Point( x, diff --git a/src/gui.js b/src/gui.js index 4f3f8fbb..f5411578 100644 --- a/src/gui.js +++ b/src/gui.js @@ -5134,7 +5134,8 @@ IDE_Morph.prototype.exportGlobalBlocks = function () { if (this.stage.globalBlocks.length > 0) { new BlockExportDialogMorph( this.serializer, - this.stage.globalBlocks + this.stage.globalBlocks, + this ).popUp(this.world()); } else { this.inform(