kopia lustrzana https://github.com/backface/turtlestitch
change “delete” behavior in context menus
to only delete this particular blocks (and reconnect the next block to the previous one)pull/3/merge
rodzic
cd416bc9a9
commit
2f864cd7de
43
blocks.js
43
blocks.js
|
@ -155,7 +155,7 @@ DialogBoxMorph, BlockInputFragmentMorph, PrototypeHatBlockMorph, Costume*/
|
||||||
|
|
||||||
// Global stuff ////////////////////////////////////////////////////////
|
// Global stuff ////////////////////////////////////////////////////////
|
||||||
|
|
||||||
modules.blocks = '2014-July-06';
|
modules.blocks = '2014-July-08';
|
||||||
|
|
||||||
|
|
||||||
var SyntaxElementMorph;
|
var SyntaxElementMorph;
|
||||||
|
@ -2157,16 +2157,18 @@ BlockMorph.prototype.developersMenu = function () {
|
||||||
|
|
||||||
BlockMorph.prototype.hidePrimitive = function () {
|
BlockMorph.prototype.hidePrimitive = function () {
|
||||||
var ide = this.parentThatIsA(IDE_Morph),
|
var ide = this.parentThatIsA(IDE_Morph),
|
||||||
|
dict,
|
||||||
cat;
|
cat;
|
||||||
if (!ide) {return; }
|
if (!ide) {return; }
|
||||||
StageMorph.prototype.hiddenPrimitives[this.selector] = true;
|
StageMorph.prototype.hiddenPrimitives[this.selector] = true;
|
||||||
cat = {
|
dict = {
|
||||||
doWarp: 'control',
|
doWarp: 'control',
|
||||||
reifyScript: 'operators',
|
reifyScript: 'operators',
|
||||||
reifyReporter: 'operators',
|
reifyReporter: 'operators',
|
||||||
reifyPredicate: 'operators',
|
reifyPredicate: 'operators',
|
||||||
doDeclareVariables: 'variables'
|
doDeclareVariables: 'variables'
|
||||||
}[this.selector] || this.category;
|
};
|
||||||
|
cat = dict[this.selector] || this.category;
|
||||||
if (cat === 'lists') {cat = 'variables'; }
|
if (cat === 'lists') {cat = 'variables'; }
|
||||||
ide.flushBlocksCache(cat);
|
ide.flushBlocksCache(cat);
|
||||||
ide.refreshPalette();
|
ide.refreshPalette();
|
||||||
|
@ -3345,6 +3347,10 @@ CommandBlockMorph.prototype.isStop = function () {
|
||||||
// CommandBlockMorph deleting
|
// CommandBlockMorph deleting
|
||||||
|
|
||||||
CommandBlockMorph.prototype.userDestroy = function () {
|
CommandBlockMorph.prototype.userDestroy = function () {
|
||||||
|
if (this.nextBlock()) {
|
||||||
|
this.userDestroyJustThis();
|
||||||
|
return;
|
||||||
|
}
|
||||||
var cslot = this.parentThatIsA(CSlotMorph);
|
var cslot = this.parentThatIsA(CSlotMorph);
|
||||||
this.destroy();
|
this.destroy();
|
||||||
if (cslot) {
|
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 drawing:
|
||||||
|
|
||||||
CommandBlockMorph.prototype.drawNew = function () {
|
CommandBlockMorph.prototype.drawNew = function () {
|
||||||
|
|
|
@ -2185,3 +2185,4 @@ ______
|
||||||
* GUI, Objects: fixed scrolling glitch in the palette, thanks, Kunal!
|
* GUI, Objects: fixed scrolling glitch in the palette, thanks, Kunal!
|
||||||
* GUI, Objects: add keyboard shortcut for “new project”: ctr-n
|
* GUI, Objects: add keyboard shortcut for “new project”: ctr-n
|
||||||
* revert changes made for JSLint’s sake after the issue was fixed in JSLint
|
* revert changes made for JSLint’s sake after the issue was fixed in JSLint
|
||||||
|
* Blocks: change “delete” behavior in context menus to only delete this particular blocks (and reconnect the next block to the previous one)
|
||||||
|
|
Ładowanie…
Reference in New Issue