MCPcopy
hub / github.com/dataarts/dat.gui / constructor

Method constructor

src/dat/controllers/OptionController.js:30–67  ·  view source on GitHub ↗
(object, property, opts)

Source from the content-addressed store, hash-verified

28 */
29class OptionController extends Controller {
30 constructor(object, property, opts) {
31 super(object, property);
32
33 let options = opts;
34
35 const _this = this;
36
37 /**
38 * The drop down menu
39 * @ignore
40 */
41 this.__select = document.createElement('select');
42
43 if (common.isArray(options)) {
44 const map = {};
45 common.each(options, function(element) {
46 map[element] = element;
47 });
48 options = map;
49 }
50
51 common.each(options, function(value, key) {
52 const opt = document.createElement('option');
53 opt.innerHTML = key;
54 opt.setAttribute('value', value);
55 _this.__select.appendChild(opt);
56 });
57
58 // Acknowledge original value
59 this.updateDisplay();
60
61 dom.bind(this.__select, 'change', function() {
62 const desiredValue = this.options[this.selectedIndex].value;
63 _this.setValue(desiredValue);
64 });
65
66 this.domElement.appendChild(this.__select);
67 }
68
69 setValue(v) {
70 const toReturn = super.setValue(v);

Callers

nothing calls this directly

Calls 2

updateDisplayMethod · 0.95
setValueMethod · 0.45

Tested by

no test coverage detected