change “delete” behavior in context menus

to only delete this particular blocks (and reconnect the next block to
the previous one)
pull/3/merge
jmoenig 2014-07-08 18:46:52 +02:00
rodzic cd416bc9a9
commit 2f864cd7de
2 zmienionych plików z 41 dodań i 3 usunięć

Wyświetl plik

@ -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 () {

Wyświetl plik

@ -2185,3 +2185,4 @@ ______
* GUI, Objects: fixed scrolling glitch in the palette, thanks, Kunal!
* GUI, Objects: add keyboard shortcut for “new project”: ctr-n
* revert changes made for JSLints 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)