summaryrefslogtreecommitdiff
path: root/blocks.js
diff options
context:
space:
mode:
authorjmoenig <jens@moenig.org>2014-07-08 18:46:52 +0200
committerjmoenig <jens@moenig.org>2014-07-08 18:46:52 +0200
commit2f864cd7ded2505a7fbbb8c77de48972c95114b4 (patch)
tree2ff41c6d75d087f4acda9f7a38afc20041e5ac49 /blocks.js
parentcd416bc9a9f51b482f234f7392d97a72c738f663 (diff)
downloadsnap-2f864cd7ded2505a7fbbb8c77de48972c95114b4.tar.gz
snap-2f864cd7ded2505a7fbbb8c77de48972c95114b4.zip
change “delete” behavior in context menus
to only delete this particular blocks (and reconnect the next block to the previous one)
Diffstat (limited to 'blocks.js')
-rw-r--r--blocks.js43
1 files changed, 40 insertions, 3 deletions
diff --git a/blocks.js b/blocks.js
index 68a5e70..49eb111 100644
--- a/blocks.js
+++ b/blocks.js
@@ -155,7 +155,7 @@ DialogBoxMorph, BlockInputFragmentMorph, PrototypeHatBlockMorph, Costume*/
// Global stuff ////////////////////////////////////////////////////////
-modules.blocks = '2014-July-06';
+modules.blocks = '2014-July-08';
var SyntaxElementMorph;
@@ -2157,16 +2157,18 @@ BlockMorph.prototype.developersMenu = function () {
BlockMorph.prototype.hidePrimitive = function () {
var ide = this.parentThatIsA(IDE_Morph),
+ dict,
cat;
if (!ide) {return; }
StageMorph.prototype.hiddenPrimitives[this.selector] = true;
- cat = {
+ dict = {
doWarp: 'control',
reifyScript: 'operators',
reifyReporter: 'operators',
reifyPredicate: 'operators',
doDeclareVariables: 'variables'
- }[this.selector] || this.category;
+ };
+ cat = dict[this.selector] || this.category;
if (cat === 'lists') {cat = 'variables'; }
ide.flushBlocksCache(cat);
ide.refreshPalette();
@@ -3345,6 +3347,10 @@ CommandBlockMorph.prototype.isStop = function () {
// CommandBlockMorph deleting
CommandBlockMorph.prototype.userDestroy = function () {
+ if (this.nextBlock()) {
+ this.userDestroyJustThis();
+ return;
+ }
var cslot = this.parentThatIsA(CSlotMorph);
this.destroy();
if (cslot) {
@@ -3352,6 +3358,37 @@ CommandBlockMorph.prototype.userDestroy = function () {
}
};
+CommandBlockMorph.prototype.userDestroyJustThis = function () {
+ // delete just this one block, reattach next block to the previous one,
+ var scripts = this.parentThatIsA(ScriptsMorph),
+ cs = this.parentThatIsA(CommandSlotMorph),
+ pb,
+ nb = this.nextBlock(),
+ above,
+ cslot = this.parentThatIsA(CSlotMorph);
+
+ if (this.parent) {
+ pb = this.parent.parentThatIsA(CommandBlockMorph);
+ }
+ if (pb && (pb.nextBlock() === this)) {
+ above = pb;
+ } else if (cs && (cs.nestedBlock() === this)) {
+ above = cs;
+ }
+ this.destroy();
+ if (nb) {
+ if (above instanceof CommandSlotMorph) {
+ above.nestedBlock(nb);
+ } else if (above instanceof CommandBlockMorph) {
+ above.nextBlock(nb);
+ } else {
+ scripts.add(nb);
+ }
+ } else if (cslot) {
+ cslot.fixLayout();
+ }
+};
+
// CommandBlockMorph drawing:
CommandBlockMorph.prototype.drawNew = function () {