kopia lustrzana https://github.com/backface/turtlestitch
shadow inherited scripts on input edit, ringify/unringify, relabel action
rodzic
2c21be39ff
commit
10d164ebef
116
blocks.js
116
blocks.js
|
@ -2785,10 +2785,14 @@ BlockMorph.prototype.deleteBlock = function () {
|
||||||
|
|
||||||
BlockMorph.prototype.ringify = function () {
|
BlockMorph.prototype.ringify = function () {
|
||||||
// wrap a Ring around me
|
// wrap a Ring around me
|
||||||
var ring = new RingMorph(),
|
var ring, top, center,
|
||||||
top = this.topBlock(),
|
target = this.selectForEdit(); // copy-on-edit
|
||||||
center = top.fullBounds().center();
|
if (target !== this) {
|
||||||
|
return this.ringify.call(target);
|
||||||
|
}
|
||||||
|
ring = new RingMorph();
|
||||||
|
top = this.topBlock();
|
||||||
|
center = top.fullBounds().center();
|
||||||
if (this.parent === null) {return null; }
|
if (this.parent === null) {return null; }
|
||||||
top.fullChanged();
|
top.fullChanged();
|
||||||
if (this.parent instanceof SyntaxElementMorph) {
|
if (this.parent instanceof SyntaxElementMorph) {
|
||||||
|
@ -2810,17 +2814,18 @@ BlockMorph.prototype.ringify = function () {
|
||||||
}
|
}
|
||||||
this.fixBlockColor(null, true);
|
this.fixBlockColor(null, true);
|
||||||
top.fullChanged();
|
top.fullChanged();
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
BlockMorph.prototype.unringify = function () {
|
BlockMorph.prototype.unringify = function () {
|
||||||
// remove a Ring around me, if any
|
// remove a Ring around me, if any
|
||||||
var ring = this.parent.parentThatIsA(RingMorph),
|
var ring, top, center, scripts, block,
|
||||||
top = this.topBlock(),
|
target = this.selectForEdit(); // copy-on-edit
|
||||||
scripts = this.parentThatIsA(ScriptsMorph),
|
if (target !== this) {
|
||||||
block,
|
return this.unringify.call(target);
|
||||||
center;
|
}
|
||||||
|
ring = this.parent.parentThatIsA(RingMorph);
|
||||||
|
top = this.topBlock();
|
||||||
|
scripts = this.parentThatIsA(ScriptsMorph);
|
||||||
if (ring === null) {return null; }
|
if (ring === null) {return null; }
|
||||||
block = ring.contents();
|
block = ring.contents();
|
||||||
center = ring.center();
|
center = ring.center();
|
||||||
|
@ -2845,9 +2850,14 @@ BlockMorph.prototype.unringify = function () {
|
||||||
};
|
};
|
||||||
|
|
||||||
BlockMorph.prototype.relabel = function (alternativeSelectors) {
|
BlockMorph.prototype.relabel = function (alternativeSelectors) {
|
||||||
var menu = new MenuMorph(this),
|
var menu, oldInputs, myself,
|
||||||
oldInputs = this.inputs(),
|
target = this.selectForEdit(); // copy-on-edit
|
||||||
myself = this;
|
if (target !== this) {
|
||||||
|
return this.relabel.call(target, alternativeSelectors);
|
||||||
|
}
|
||||||
|
menu = new MenuMorph(this);
|
||||||
|
oldInputs = this.inputs();
|
||||||
|
myself = this;
|
||||||
alternativeSelectors.forEach(function (sel) {
|
alternativeSelectors.forEach(function (sel) {
|
||||||
var block = SpriteMorph.prototype.blockForSelector(sel);
|
var block = SpriteMorph.prototype.blockForSelector(sel);
|
||||||
block.restoreInputs(oldInputs);
|
block.restoreInputs(oldInputs);
|
||||||
|
@ -4348,35 +4358,38 @@ CommandBlockMorph.prototype.isStop = function () {
|
||||||
|
|
||||||
CommandBlockMorph.prototype.userDestroy = function () {
|
CommandBlockMorph.prototype.userDestroy = function () {
|
||||||
var target = this.selectForEdit(); // enable copy-on-edit
|
var target = this.selectForEdit(); // enable copy-on-edit
|
||||||
if (target.nextBlock()) {
|
if (target !== this) {
|
||||||
target.userDestroyJustThis();
|
return this.userDestroy.call(target);
|
||||||
|
}
|
||||||
|
if (this.nextBlock()) {
|
||||||
|
this.userDestroyJustThis();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var scripts = target.parentThatIsA(ScriptsMorph),
|
var scripts = this.parentThatIsA(ScriptsMorph),
|
||||||
ide = target.parentThatIsA(IDE_Morph),
|
ide = this.parentThatIsA(IDE_Morph),
|
||||||
parent = target.parentThatIsA(SyntaxElementMorph),
|
parent = this.parentThatIsA(SyntaxElementMorph),
|
||||||
cslot = target.parentThatIsA(CSlotMorph);
|
cslot = this.parentThatIsA(CSlotMorph);
|
||||||
|
|
||||||
// for undrop / redrop
|
// for undrop / redrop
|
||||||
if (scripts) {
|
if (scripts) {
|
||||||
scripts.clearDropInfo();
|
scripts.clearDropInfo();
|
||||||
scripts.lastDroppedBlock = target;
|
scripts.lastDroppedBlock = this;
|
||||||
scripts.recordDrop(target.situation());
|
scripts.recordDrop(this.situation());
|
||||||
scripts.dropRecord.action = 'delete';
|
scripts.dropRecord.action = 'delete';
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ide) {
|
if (ide) {
|
||||||
// also stop all active processes hatted by this block
|
// also stop all active processes hatted by this block
|
||||||
ide.removeBlock(target);
|
ide.removeBlock(this);
|
||||||
} else {
|
} else {
|
||||||
target.destroy();
|
this.destroy();
|
||||||
}
|
}
|
||||||
if (cslot) {
|
if (cslot) {
|
||||||
cslot.fixLayout();
|
cslot.fixLayout();
|
||||||
}
|
}
|
||||||
if (parent) {
|
if (parent) {
|
||||||
parent.reactToGrabOf(target); // fix highlight
|
parent.reactToGrabOf(this); // fix highlight
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -5200,19 +5213,22 @@ ReporterBlockMorph.prototype.exportResultPic = function () {
|
||||||
ReporterBlockMorph.prototype.userDestroy = function () {
|
ReporterBlockMorph.prototype.userDestroy = function () {
|
||||||
// make sure to restore default slot of parent block
|
// make sure to restore default slot of parent block
|
||||||
var target = this.selectForEdit(); // enable copy-on-edit
|
var target = this.selectForEdit(); // enable copy-on-edit
|
||||||
|
if (target !== this) {
|
||||||
|
return this.userDestroy.call(target);
|
||||||
|
}
|
||||||
|
|
||||||
// for undrop / redrop
|
// for undrop / redrop
|
||||||
var scripts = target.parentThatIsA(ScriptsMorph);
|
var scripts = this.parentThatIsA(ScriptsMorph);
|
||||||
if (scripts) {
|
if (scripts) {
|
||||||
scripts.clearDropInfo();
|
scripts.clearDropInfo();
|
||||||
scripts.lastDroppedBlock = target;
|
scripts.lastDroppedBlock = this;
|
||||||
scripts.recordDrop(target.situation());
|
scripts.recordDrop(this.situation());
|
||||||
scripts.dropRecord.action = 'delete';
|
scripts.dropRecord.action = 'delete';
|
||||||
}
|
}
|
||||||
|
|
||||||
target.topBlock().fullChanged();
|
this.topBlock().fullChanged();
|
||||||
target.prepareToBeGrabbed(target.world().hand);
|
this.prepareToBeGrabbed(this.world().hand);
|
||||||
target.destroy();
|
this.destroy();
|
||||||
};
|
};
|
||||||
|
|
||||||
// ReporterBlockMorph drawing:
|
// ReporterBlockMorph drawing:
|
||||||
|
@ -7970,6 +7986,11 @@ InputSlotMorph.prototype.setContents = function (aStringOrFloat) {
|
||||||
this.constant = isConstant ? aStringOrFloat : null;
|
this.constant = isConstant ? aStringOrFloat : null;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
InputSlotMorph.prototype.userSetContents = function (aStringOrFloat) {
|
||||||
|
// enable copy-on-edit for inherited scripts
|
||||||
|
this.selectForEdit().setContents(aStringOrFloat);
|
||||||
|
};
|
||||||
|
|
||||||
// InputSlotMorph drop-down menu:
|
// InputSlotMorph drop-down menu:
|
||||||
|
|
||||||
InputSlotMorph.prototype.dropDownMenu = function (enableKeyboard) {
|
InputSlotMorph.prototype.dropDownMenu = function (enableKeyboard) {
|
||||||
|
@ -7987,7 +8008,7 @@ InputSlotMorph.prototype.dropDownMenu = function (enableKeyboard) {
|
||||||
InputSlotMorph.prototype.menuFromDict = function (choices, noEmptyOption) {
|
InputSlotMorph.prototype.menuFromDict = function (choices, noEmptyOption) {
|
||||||
var key,
|
var key,
|
||||||
menu = new MenuMorph(
|
menu = new MenuMorph(
|
||||||
this.setContents,
|
this.userSetContents,
|
||||||
null,
|
null,
|
||||||
this,
|
this,
|
||||||
this.fontSize
|
this.fontSize
|
||||||
|
@ -8433,10 +8454,15 @@ InputSlotMorph.prototype.fixLayout = function () {
|
||||||
// InputSlotMorph events:
|
// InputSlotMorph events:
|
||||||
|
|
||||||
InputSlotMorph.prototype.mouseDownLeft = function (pos) {
|
InputSlotMorph.prototype.mouseDownLeft = function (pos) {
|
||||||
|
var world;
|
||||||
if (this.isReadOnly || this.arrow().bounds.containsPoint(pos)) {
|
if (this.isReadOnly || this.arrow().bounds.containsPoint(pos)) {
|
||||||
this.escalateEvent('mouseDownLeft', pos);
|
this.escalateEvent('mouseDownLeft', pos);
|
||||||
} else {
|
} else {
|
||||||
this.contents().edit();
|
world = this.world();
|
||||||
|
if (world) {
|
||||||
|
world.stopEditing();
|
||||||
|
}
|
||||||
|
this.selectForEdit().contents().edit();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -9049,7 +9075,12 @@ BooleanSlotMorph.prototype.setContents = function (boolOrNull, silently) {
|
||||||
};
|
};
|
||||||
|
|
||||||
BooleanSlotMorph.prototype.toggleValue = function () {
|
BooleanSlotMorph.prototype.toggleValue = function () {
|
||||||
var ide = this.parentThatIsA(IDE_Morph);
|
var target = this.selectForEdit(),
|
||||||
|
ide;
|
||||||
|
if (target !== this) {
|
||||||
|
return this.toggleValue.call(target);
|
||||||
|
}
|
||||||
|
ide = this.parentThatIsA(IDE_Morph);
|
||||||
if (this.isStatic || this.isBinary()) {
|
if (this.isStatic || this.isBinary()) {
|
||||||
this.setContents(!this.value, true);
|
this.setContents(!this.value, true);
|
||||||
} else {
|
} else {
|
||||||
|
@ -11220,7 +11251,7 @@ ColorSlotMorph.prototype.getUserColor = function () {
|
||||||
// ColorSlotMorph events:
|
// ColorSlotMorph events:
|
||||||
|
|
||||||
ColorSlotMorph.prototype.mouseClickLeft = function () {
|
ColorSlotMorph.prototype.mouseClickLeft = function () {
|
||||||
this.getUserColor();
|
this.selectForEdit().getUserColor();
|
||||||
};
|
};
|
||||||
|
|
||||||
// ColorSlotMorph evaluating:
|
// ColorSlotMorph evaluating:
|
||||||
|
@ -11616,29 +11647,30 @@ MultiArgMorph.prototype.mouseClickLeft = function (pos) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// if the <shift> key is pressed, repeat action 3 times
|
// if the <shift> key is pressed, repeat action 3 times
|
||||||
var arrows = this.arrows(),
|
var target = this.selectForEdit(),
|
||||||
|
arrows = target.arrows(),
|
||||||
leftArrow = arrows.children[0],
|
leftArrow = arrows.children[0],
|
||||||
rightArrow = arrows.children[1],
|
rightArrow = arrows.children[1],
|
||||||
repetition = this.world().currentKey === 16 ? 3 : 1,
|
repetition = target.world().currentKey === 16 ? 3 : 1,
|
||||||
i;
|
i;
|
||||||
|
|
||||||
this.startLayout();
|
target.startLayout();
|
||||||
if (rightArrow.bounds.containsPoint(pos)) {
|
if (rightArrow.bounds.containsPoint(pos)) {
|
||||||
for (i = 0; i < repetition; i += 1) {
|
for (i = 0; i < repetition; i += 1) {
|
||||||
if (rightArrow.isVisible) {
|
if (rightArrow.isVisible) {
|
||||||
this.addInput();
|
target.addInput();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (leftArrow.bounds.containsPoint(pos)) {
|
} else if (leftArrow.bounds.containsPoint(pos)) {
|
||||||
for (i = 0; i < repetition; i += 1) {
|
for (i = 0; i < repetition; i += 1) {
|
||||||
if (leftArrow.isVisible) {
|
if (leftArrow.isVisible) {
|
||||||
this.removeInput();
|
target.removeInput();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
this.escalateEvent('mouseClickLeft', pos);
|
target.escalateEvent('mouseClickLeft', pos);
|
||||||
}
|
}
|
||||||
this.endLayout();
|
target.endLayout();
|
||||||
};
|
};
|
||||||
|
|
||||||
// MultiArgMorph menu:
|
// MultiArgMorph menu:
|
||||||
|
|
|
@ -3464,6 +3464,7 @@ Fixes:
|
||||||
* Blocks: shadow inherited scripts on deleting blocks and comments via the context menu
|
* Blocks: shadow inherited scripts on deleting blocks and comments via the context menu
|
||||||
* Blocks: shadow inherited scripts on “clean up”
|
* Blocks: shadow inherited scripts on “clean up”
|
||||||
* Blocks, Objects: shadow inherited scripts on keyboard entry
|
* Blocks, Objects: shadow inherited scripts on keyboard entry
|
||||||
|
* Blocks: shadow inherited scripts on input edit, ringify/unringify, relabel action
|
||||||
|
|
||||||
|
|
||||||
Features:
|
Features:
|
||||||
|
|
Ładowanie…
Reference in New Issue