From c0e3bbecca74a6c2d00bac63381a6667c9683b33 Mon Sep 17 00:00:00 2001 From: jmoenig Date: Tue, 15 Oct 2019 08:22:21 +0200 Subject: [PATCH] prevent switching to another sprite if a block editor is open so local blocks of different sprites don't mix --- HISTORY.md | 6 +++++- snap.html | 2 +- src/gui.js | 20 +++++++++++++++++--- 3 files changed, 23 insertions(+), 5 deletions(-) diff --git a/HISTORY.md b/HISTORY.md index e42a0fc4..318cb2ab 100755 --- a/HISTORY.md +++ b/HISTORY.md @@ -6,8 +6,9 @@ * accept a list of pixels in the SWITCH TO COSTUME block * URLs in dialog boxes are now clickable and can open new browser tabs, thanks, Brian Broll! * **Notable Changes:** -* **Notable Fixes:** * made "i" upvar inside FOR loop's C-Shape slot mutable by user script + * prevent switching to another sprite if a block editor is open (so local blocks of different sprites don't mix) +* **Notable Fixes:** * typing strings into the search-field again shows relevant blocks (regression from IME) * fixed project dialog's search-field behevior (regression from IME) * morphic collision detection off-by-1 fix, thanks, Dariusz! @@ -20,6 +21,9 @@ * Galician, thanks, Bernat * Turkish, thanks, Turgut! +### 2019-10-15 +* gui: prevent switching to another sprite if a block editor is open (so local blocks of different sprites don't mix) + ### 2019-10-14 * morphic: new "reactToInput" text-editing event * objects: fixed #2485 (find blocks and text-entry mode feature) diff --git a/snap.html b/snap.html index 1f7b6961..dc8d068a 100755 --- a/snap.html +++ b/snap.html @@ -9,7 +9,7 @@ - + diff --git a/src/gui.js b/src/gui.js index 4959bf05..15acf016 100644 --- a/src/gui.js +++ b/src/gui.js @@ -60,7 +60,7 @@ /*global modules, Morph, SpriteMorph, SyntaxElementMorph, Color, Cloud, ListWatcherMorph, TextMorph, newCanvas, useBlurredShadows, VariableFrame, -StringMorph, Point, MenuMorph, morphicVersion, DialogBoxMorph,normalizeCanvas, +StringMorph, Point, MenuMorph, morphicVersion, DialogBoxMorph, normalizeCanvas, ToggleButtonMorph, contains, ScrollFrameMorph, StageMorph, PushButtonMorph, sb, InputFieldMorph, FrameMorph, Process, nop, SnapSerializer, ListMorph, detect, AlignmentMorph, TabMorph, Costume, MorphicPreferences, Sound, BlockMorph, @@ -71,11 +71,12 @@ CommentMorph, CommandBlockMorph, BooleanSlotMorph, RingReporterSlotMorph, BlockLabelPlaceHolderMorph, Audio, SpeechBubbleMorph, ScriptFocusMorph, XML_Element, WatcherMorph, BlockRemovalDialogMorph, saveAs, TableMorph, isSnapObject, isRetinaEnabled, disableRetinaSupport, enableRetinaSupport, -isRetinaSupported, SliderMorph, Animation, BoxMorph, MediaRecorder*/ +isRetinaSupported, SliderMorph, Animation, BoxMorph, MediaRecorder, +BlockEditorMorph, BlockDialogMorph*/ // Global stuff //////////////////////////////////////////////////////// -modules.gui = '2019-October-14'; +modules.gui = '2019-October-15'; // Declarations @@ -2151,6 +2152,19 @@ IDE_Morph.prototype.stopAllScripts = function () { }; IDE_Morph.prototype.selectSprite = function (sprite) { + // prevent switching to another sprite if a block editor is open + // so local blocks of different sprites don't mix + if ( + detect( + this.world().children, + function (morph) { + return morph instanceof BlockEditorMorph || + morph instanceof BlockDialogMorph; + } + ) + ) { + return; + } if (this.currentSprite && this.currentSprite.scripts.focus) { this.currentSprite.scripts.focus.stopEditing(); }