summaryrefslogtreecommitdiff
path: root/byob.js
diff options
context:
space:
mode:
authorjmoenig <jens@moenig.org>2013-11-04 17:55:11 +0100
committerjmoenig <jens@moenig.org>2013-11-04 17:55:11 +0100
commit8a60ec998e303c34ed6e1f58f4ec2b33ff3f4be5 (patch)
tree8b51b8028fdb816538a81ebc26f2ffac9ba77852 /byob.js
parentc95c1a223def1cc92c3df0b69ac0d2c5789a9f00 (diff)
downloadsnap-8a60ec998e303c34ed6e1f58f4ec2b33ff3f4be5.tar.gz
snap-8a60ec998e303c34ed6e1f58f4ec2b33ff3f4be5.zip
customizable drop-down menus for input slots
still experimental and incomplete and therefore commented out (inactive) for now
Diffstat (limited to 'byob.js')
-rw-r--r--byob.js42
1 files changed, 42 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,