Skip to content

Commit

Permalink
added showScriptBalloonAt() and closePopUps() API methods
Browse files Browse the repository at this point in the history
  • Loading branch information
jmoenig committed Feb 20, 2024
1 parent 6227ed3 commit c25731e
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 4 deletions.
2 changes: 2 additions & 0 deletions HISTORY.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@

* **New Features:**
* new "Lirin" costume series, thanks, Meghan and Brian!
* new showScriptBalloonAt() and closePopUps() API methods

2024-02-20
* new dev version for v9.2.7
* added new Lirin costumes, thanks, Brian and Meghan!
* api: added showScriptBalloonAt() and closePopUps() API methods

## 9.2.6:
* **Notable Changes:**
Expand Down
4 changes: 2 additions & 2 deletions snap.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<script src="src/morphic.js?version=2024-02-12"></script>
<script src="src/symbols.js?version=2024-01-24"></script>
<script src="src/widgets.js?version=2023-05-24"></script>
<script src="src/blocks.js?version=2024-01-23"></script>
<script src="src/blocks.js?version=2024-02-20"></script>
<script src="src/threads.js?version=2024-01-15"></script>
<script src="src/objects.js?version=2024-01-15"></script>
<script src="src/scenes.js?version=2022-10-29"></script>
Expand All @@ -33,7 +33,7 @@
<script src="src/store.js?version=2023-07-27"></script>
<script src="src/locale.js?version=2024-02-12"></script>
<script src="src/cloud.js?version=2023-04-12"></script>
<script src="src/api.js?version=2024-02-12"></script>
<script src="src/api.js?version=2024-02-20"></script>
<script src="src/sha512.js?version=2019-06-27"></script>
<script src="src/FileSaver.min.js?version=2019-06-27"></script>
<script>
Expand Down
19 changes: 18 additions & 1 deletion src/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ detect, isSnapObject, VariableFrame*/

// Global stuff ////////////////////////////////////////////////////////

modules.api = '2024-February-12';
modules.api = '2024-February-20';

// IDE_Morph external communication API
/*
Expand Down Expand Up @@ -311,6 +311,23 @@ IDE_Morph.prototype.unflashSpriteScripts = function (name) {
this.spriteNamed(name).scripts.unflash();
};

IDE_Morph.prototype.showScriptBalloonAt = function (contents, charIdx, name) {
// popup a balloon at the innermost block of the scripts of the sprite
// indicated by name or the current sprite or stage if none that corresponds
// to the index of the text given the current codification mapping, and
// display the given contents, which can be a string, number, costume,
// morph, canvas, list, table etc. (anything first-class in Snap!)
var scripts = this.spriteNamed(name).scripts;
// scripts.unflash();
// scripts.flashCodeIdx(charIdx, contents);
scripts.balloonCodeIdx(charIdx, contents);
};

IDE_Morph.prototype.closePopUps = function () {
// remove all pop-up menus and balloons, if any
this.world().hand.destroyTemporaries();
};

IDE_Morph.prototype.unsavedChanges = function () {
return this.hasUnsavedEdits();
};
Expand Down
11 changes: 10 additions & 1 deletion src/blocks.js
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ SVG_Costume, embedMetadataPNG, ThreadManager, snapEquals*/

// Global stuff ////////////////////////////////////////////////////////

modules.blocks = '2024-January-23';
modules.blocks = '2024-February-20';

var SyntaxElementMorph;
var BlockMorph;
Expand Down Expand Up @@ -9287,6 +9287,15 @@ ScriptsMorph.prototype.unflash = function () {

};

ScriptsMorph.prototype.balloonCodeIdx = function (idx, contents) {
// highlight the innermost block located in the textual code indicated
// by the given character index. Optional color string, form "r,g,b[,a]".
var block = this.blockAtIdx(idx);
if (block) {
block.showBubble(contents);
}
};

// ArgMorph //////////////////////////////////////////////////////////

/*
Expand Down

0 comments on commit c25731e

Please sign in to comment.