summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--byob.js42
-rwxr-xr-xhistory.txt1
2 files changed, 43 insertions, 0 deletions
diff --git a/byob.js b/byob.js
index 6bb0eca..855b619 100644
--- a/byob.js
+++ b/byob.js
@@ -383,6 +383,48 @@ CustomCommandBlockMorph.prototype.refreshDefaults = function () {
});
};
+/*
+custom drop down menus, still incomplete, commented out for now
+
+CustomCommandBlockMorph.prototype.refreshDefaults = function () {
+ // fill my editable slots with the defaults specified in my definition
+ var inputs = this.inputs(), idx = 0, myself = this, dflt;
+
+ inputs.forEach(function (inp) {
+ if (inp instanceof InputSlotMorph) {
+ dflt = myself.parseDefault(
+ myself.definition.defaultValueOfInputIdx(idx)
+ );
+ inp.choices = dflt.menu;
+ inp.setContents(dflt.value);
+ }
+ idx += 1;
+ });
+};
+
+CustomCommandBlockMorph.prototype.parseDefault = function (str) {
+ // experimental shot at custom drop downs for input slots,
+ // answer an object of form: {value: 'bar', menu: {key: val, ...}}
+ var ans = {},
+ menu = {},
+ tokens;
+ if (str.indexOf('&') !== -1) {
+ tokens = str.split('&');
+ ans.value = tokens[0];
+ if (tokens[1]) {
+ tokens[1].split(',').forEach(function (entry) {
+ var pair = entry.split('=');
+ if (pair[0]) {
+ menu[pair[0]] = pair[1] || pair[0];
+ }
+ });
+ ans.menu = menu;
+ }
+ }
+ return ans;
+};
+*/
+
CustomCommandBlockMorph.prototype.refreshPrototype = function () {
// create my label parts from my (edited) fragments only
var hat,
diff --git a/history.txt b/history.txt
index 99e3be2..4f39c95 100755
--- a/history.txt
+++ b/history.txt
@@ -1981,3 +1981,4 @@ ______
———
* GUI: filter quotation marks from project names (for backend index)
* BYOB: only show symbol menu for label fragments
+* BYOB: customizable drop-down menus for input slots (experimental, commented out)