support deleting and inserting individual variadic slots

under construction
snap7
Jens Mönig 2022-01-25 19:00:17 +01:00
rodzic f5c330f404
commit bc01598ef8
3 zmienionych plików z 64 dodań i 13 usunięć

Wyświetl plik

@ -4,12 +4,16 @@
* **New Features:**
* support dragging blocks out from result bubbles, and from speech balloons and variable watchers when in edit mode
* support deleting and inserting individual variadic slots
* **Notable Changes:**
* **Notable Fixes:**
* fixed layout for scrolling custom categories, thanks, Eckart, for the bug report!
* **Documentation Updates:**
* **Translation Updates:**
### 2022-01-25
* blocks: support deleting and inserting individual variadic slots
### 2022-01-23
* morphic: added Node >> childThatIsA
* tables: support dragging blocks out from table views

Wyświetl plik

@ -16,7 +16,7 @@
<script src="src/morphic.js?version=2022-01-23"></script>
<script src="src/symbols.js?version=2021-03-03"></script>
<script src="src/widgets.js?version=2021-17-09"></script>
<script src="src/blocks.js?version=2022-01-22"></script>
<script src="src/blocks.js?version=2022-01-25"></script>
<script src="src/threads.js?version=2022-01-21"></script>
<script src="src/objects.js?version=2022-01-23"></script>
<script src="src/scenes.js?version=2021-11-24"></script>

Wyświetl plik

@ -160,7 +160,7 @@ CustomCommandBlockMorph, ToggleButtonMorph, DialMorph, SnapExtensions*/
// Global stuff ////////////////////////////////////////////////////////
modules.blocks = '2022-January-22';
modules.blocks = '2022-January-25';
var SyntaxElementMorph;
var BlockMorph;
@ -10419,23 +10419,43 @@ InputSlotMorph.prototype.freshTextEdit = function (aStringOrTextMorph) {
InputSlotMorph.prototype.userMenu = function () {
var menu = new MenuMorph(this);
if (!StageMorph.prototype.enableCodeMapping) {
if (!StageMorph.prototype.enableCodeMapping &&
!(this.parent instanceof MultiArgMorph)) {
return this.parent.userMenu();
}
if (this.isNumeric) {
menu.addItem(
'code number mapping...',
'mapNumberToCode'
);
} else {
menu.addItem(
'code string mapping...',
'mapStringToCode'
);
if (this.parent instanceof MultiArgMorph &&
this.parentThatIsA(ScriptsMorph)) {
if (!this.parent.maxInputs ||
(this.parent.children.length <= this.parent.maxInputs)) {
menu.addItem(
'insert',
() => this.parent.insertNewInputBefore(this)
);
}
if (this.parent.children.length >= this.parent.minInputs) {
menu.addItem(
'delete',
() => this.parent.deleteSlot(this)
);
}
}
if (StageMorph.prototype.enableCodeMapping) {
if (this.isNumeric) {
menu.addItem(
'code number mapping...',
'mapNumberToCode'
);
} else {
menu.addItem(
'code string mapping...',
'mapStringToCode'
);
}
}
return menu;
};
// InputSlotMorph reacting to user choices
/*
@ -12313,6 +12333,33 @@ MultiArgMorph.prototype.refresh = function () {
});
};
// MultiArgMorph deleting & inserting slots:
// caution, only call these methods with "primitive" inputs,
// since they don't preserve embedded blocks (yes, on purpose)
MultiArgMorph.prototype.deleteSlot = function (anInput) {
if (this.children.length <= this.minInputs + 1) {
return;
}
this.removeChild(anInput);
this.fixLayout();
};
MultiArgMorph.prototype.insertNewInputBefore = function (anInput) { // +++
var idx = this.children.indexOf(anInput),
newPart = this.labelPart(this.slotSpec);
if (this.maxInputs && (this.children.length > this.maxInputs)) {
return;
}
newPart.parent = this;
this.children.splice(idx, 0, newPart);
newPart.fixLayout();
this.fixLayout();
return newPart;
};
// MultiArgMorph arity control:
MultiArgMorph.prototype.addInput = function (contents) {