summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjmoenig <jens@moenig.org>2013-03-18 18:31:12 +0100
committerjmoenig <jens@moenig.org>2013-03-18 18:31:12 +0100
commitfd47df9cb982c9ee6d1e71e65ce407d914f5be6a (patch)
treea9046b0e8434249aec03f9911e416295c64db396
parentf593f67d50d66e12da3861b0c5feeb320ed2e62b (diff)
downloadsnap-byow-fd47df9cb982c9ee6d1e71e65ce407d914f5be6a.tar.gz
snap-byow-fd47df9cb982c9ee6d1e71e65ce407d914f5be6a.zip
Adjust highlight when modifying active scripts
When dragging blocks out of a running script, adding blocks into a running script, or editing inputs of a running script, the script's highlight should now adjust accordingly
-rw-r--r--blocks.js19
-rwxr-xr-xhistory.txt3
2 files changed, 21 insertions, 1 deletions
diff --git a/blocks.js b/blocks.js
index 25e360a..ee5907e 100644
--- a/blocks.js
+++ b/blocks.js
@@ -557,6 +557,10 @@ SyntaxElementMorph.prototype.reactToGrabOf = function (grabbedMorph) {
topBlock.allComments().forEach(function (comment) {
comment.align(topBlock);
});
+ if (topBlock.getHighlight()) {
+ topBlock.removeHighlight();
+ topBlock.addHighlight();
+ }
}
};
@@ -1148,6 +1152,7 @@ SyntaxElementMorph.prototype.fixLayout = function () {
1 : Math.floor(fontHeight(this.fontSize) / 3),
bottomCorrection,
needsHighlight = false,
+ top = this.topBlock(),
initialExtent = this.extent();
if ((this instanceof MultiArgMorph) && (this.slotSpec !== '%c')) {
@@ -1366,6 +1371,12 @@ SyntaxElementMorph.prototype.fixLayout = function () {
}
}
+ // fix highlights, if any
+ if (top.getHighlight()) {
+ top.removeHighlight();
+ top.addHighlight();
+ }
+
// restore highlight:
if (needsHighlight) {
this.addHighlight();
@@ -2481,6 +2492,14 @@ BlockMorph.prototype.snap = function () {
top.allComments().forEach(function (comment) {
comment.align(top);
});
+ // fix highlights, if any
+ if (this.getHighlight() && (this !== top)) {
+ this.removeHighlight();
+ }
+ if (top.getHighlight()) {
+ top.removeHighlight();
+ top.addHighlight();
+ }
};
// CommandBlockMorph ///////////////////////////////////////////////////
diff --git a/history.txt b/history.txt
index a7719a1..c094146 100755
--- a/history.txt
+++ b/history.txt
@@ -1528,4 +1528,5 @@ ______
------
* GUI, Blocks, BYOB, Widgets: Scaling Blocks and Scripts (shift-click on settings menu)
* Widets: numerical prompts
-* GUI: #signup URL switch \ No newline at end of file
+* GUI: #signup URL switch
+* Blocks: adjusting highlights when modifying active scripts \ No newline at end of file