diff options
| author | jmoenig <jens@moenig.org> | 2013-11-04 17:55:11 +0100 |
|---|---|---|
| committer | jmoenig <jens@moenig.org> | 2013-11-04 17:55:11 +0100 |
| commit | 8a60ec998e303c34ed6e1f58f4ec2b33ff3f4be5 (patch) | |
| tree | 8b51b8028fdb816538a81ebc26f2ffac9ba77852 /byob.js | |
| parent | c95c1a223def1cc92c3df0b69ac0d2c5789a9f00 (diff) | |
| download | snap-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.js | 42 |
1 files changed, 42 insertions, 0 deletions
@@ -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, |
