new experimental feature: duplicate block definition

Currently hidden in shift-click context menu of custom blocks
upd4.1
Jens Mönig 2017-01-24 08:46:38 +01:00
rodzic 1c1cda9969
commit ab5bbb9b56
2 zmienionych plików z 27 dodań i 2 usunięć

28
byob.js
Wyświetl plik

@ -826,6 +826,7 @@ CustomCommandBlockMorph.prototype.userMenu = function () {
var hat = this.parentThatIsA(PrototypeHatBlockMorph),
rcvr = this.receiver(),
myself = this,
shiftClicked = this.world().currentKey === 16,
menu;
function monitor(vName) {
@ -904,8 +905,15 @@ CustomCommandBlockMorph.prototype.userMenu = function () {
} else {
menu.addLine();
}
// menu.addItem("export definition...", 'exportBlockDefinition');
if (shiftClicked) {
// menu.addItem("export definition...", 'exportBlockDefinition');
menu.addItem(
"duplicate block definition...",
'duplicateBlockDefinition',
null,
new Color(100, 0, 0)
);
}
menu.addItem("delete block definition...", 'deleteBlockDefinition');
this.variables.names().forEach(function (vName) {
@ -923,6 +931,19 @@ CustomCommandBlockMorph.prototype.exportBlockDefinition = function () {
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 () {
var idx, rcvr, stage, ide, myself = this, block;
if (this.isPrototype) {
@ -1102,6 +1123,9 @@ CustomReporterBlockMorph.prototype.isInUse
CustomReporterBlockMorph.prototype.userMenu
= CustomCommandBlockMorph.prototype.userMenu;
CustomReporterBlockMorph.prototype.duplicateBlockDefinition
= CustomCommandBlockMorph.prototype.duplicateBlockDefinition;
CustomReporterBlockMorph.prototype.deleteBlockDefinition
= CustomCommandBlockMorph.prototype.deleteBlockDefinition;

Wyświetl plik

@ -3332,3 +3332,4 @@ Fixes:
------
* BYOB: changed “new line” symbol to $nl
* German translation update
* BYOB: new experimental feature: duplicate block definition (hidden in shift-click context menu)