kopia lustrzana https://github.com/backface/turtlestitch
new experimental feature: duplicate block definition
Currently hidden in shift-click context menu of custom blocksupd4.1
rodzic
1c1cda9969
commit
ab5bbb9b56
26
byob.js
26
byob.js
|
@ -826,6 +826,7 @@ CustomCommandBlockMorph.prototype.userMenu = function () {
|
||||||
var hat = this.parentThatIsA(PrototypeHatBlockMorph),
|
var hat = this.parentThatIsA(PrototypeHatBlockMorph),
|
||||||
rcvr = this.receiver(),
|
rcvr = this.receiver(),
|
||||||
myself = this,
|
myself = this,
|
||||||
|
shiftClicked = this.world().currentKey === 16,
|
||||||
menu;
|
menu;
|
||||||
|
|
||||||
function monitor(vName) {
|
function monitor(vName) {
|
||||||
|
@ -904,8 +905,15 @@ CustomCommandBlockMorph.prototype.userMenu = function () {
|
||||||
} else {
|
} else {
|
||||||
menu.addLine();
|
menu.addLine();
|
||||||
}
|
}
|
||||||
|
if (shiftClicked) {
|
||||||
// menu.addItem("export definition...", 'exportBlockDefinition');
|
// menu.addItem("export definition...", 'exportBlockDefinition');
|
||||||
|
menu.addItem(
|
||||||
|
"duplicate block definition...",
|
||||||
|
'duplicateBlockDefinition',
|
||||||
|
null,
|
||||||
|
new Color(100, 0, 0)
|
||||||
|
);
|
||||||
|
}
|
||||||
menu.addItem("delete block definition...", 'deleteBlockDefinition');
|
menu.addItem("delete block definition...", 'deleteBlockDefinition');
|
||||||
|
|
||||||
this.variables.names().forEach(function (vName) {
|
this.variables.names().forEach(function (vName) {
|
||||||
|
@ -923,6 +931,19 @@ CustomCommandBlockMorph.prototype.exportBlockDefinition = function () {
|
||||||
ide.saveXMLAs(xml, this.spec);
|
ide.saveXMLAs(xml, this.spec);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
CustomCommandBlockMorph.prototype.duplicateBlockDefinition = function () {
|
||||||
|
var dup = this.definition.copyAndBindTo(this.receiver),
|
||||||
|
ide = this.parentThatIsA(IDE_Morph);
|
||||||
|
if (this.definition.isGlobal) {
|
||||||
|
ide.stage.globalBlocks.push(dup);
|
||||||
|
} else {
|
||||||
|
this.definition.receiver.customBlocks.push(dup);
|
||||||
|
}
|
||||||
|
ide.flushPaletteCache();
|
||||||
|
ide.refreshPalette();
|
||||||
|
new BlockEditorMorph(dup, this.definition.receiver).popUp();
|
||||||
|
};
|
||||||
|
|
||||||
CustomCommandBlockMorph.prototype.deleteBlockDefinition = function () {
|
CustomCommandBlockMorph.prototype.deleteBlockDefinition = function () {
|
||||||
var idx, rcvr, stage, ide, myself = this, block;
|
var idx, rcvr, stage, ide, myself = this, block;
|
||||||
if (this.isPrototype) {
|
if (this.isPrototype) {
|
||||||
|
@ -1102,6 +1123,9 @@ CustomReporterBlockMorph.prototype.isInUse
|
||||||
CustomReporterBlockMorph.prototype.userMenu
|
CustomReporterBlockMorph.prototype.userMenu
|
||||||
= CustomCommandBlockMorph.prototype.userMenu;
|
= CustomCommandBlockMorph.prototype.userMenu;
|
||||||
|
|
||||||
|
CustomReporterBlockMorph.prototype.duplicateBlockDefinition
|
||||||
|
= CustomCommandBlockMorph.prototype.duplicateBlockDefinition;
|
||||||
|
|
||||||
CustomReporterBlockMorph.prototype.deleteBlockDefinition
|
CustomReporterBlockMorph.prototype.deleteBlockDefinition
|
||||||
= CustomCommandBlockMorph.prototype.deleteBlockDefinition;
|
= CustomCommandBlockMorph.prototype.deleteBlockDefinition;
|
||||||
|
|
||||||
|
|
|
@ -3332,3 +3332,4 @@ Fixes:
|
||||||
------
|
------
|
||||||
* BYOB: changed “new line” symbol to $nl
|
* BYOB: changed “new line” symbol to $nl
|
||||||
* German translation update
|
* German translation update
|
||||||
|
* BYOB: new experimental feature: duplicate block definition (hidden in shift-click context menu)
|
||||||
|
|
Ładowanie…
Reference in New Issue