mirror of
https://github.com/dataarts/dat.gui.git
synced 2024-12-12 04:08:27 +00:00
Added initial values for NumberController and StringController
This commit is contained in:
parent
ee543a4402
commit
e96f7110f7
@ -8,6 +8,10 @@ var Controller = function() {
|
|||||||
this.object[this.propertyName] = n;
|
this.object[this.propertyName] = n;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.getValue = function() {
|
||||||
|
return this.object[this.propertyName];
|
||||||
|
}
|
||||||
|
|
||||||
this.domElement = document.createElement('div');
|
this.domElement = document.createElement('div');
|
||||||
this.domElement.setAttribute('class', 'guidat-controller ' + this.type);
|
this.domElement.setAttribute('class', 'guidat-controller ' + this.type);
|
||||||
|
|
||||||
|
@ -9,7 +9,7 @@ var NumberController = function() {
|
|||||||
var _this = this;
|
var _this = this;
|
||||||
|
|
||||||
this.isClicked = false;
|
this.isClicked = false;
|
||||||
this.py = this.y = 0;
|
this.py = this.y = this.initialValue = this.object[this.propertyName];
|
||||||
this.inc = 0;
|
this.inc = 0;
|
||||||
|
|
||||||
// Get min and max
|
// Get min and max
|
||||||
@ -30,7 +30,7 @@ var NumberController = function() {
|
|||||||
|
|
||||||
var val = parseFloat(_this.button.value);
|
var val = parseFloat(_this.button.value);
|
||||||
if(isNaN(val)) {
|
if(isNaN(val)) {
|
||||||
_this.inc = 0;
|
_this.inc = _this.initialValue;
|
||||||
} else {
|
} else {
|
||||||
_this.inc = val;
|
_this.inc = val;
|
||||||
}
|
}
|
||||||
@ -72,6 +72,9 @@ var NumberController = function() {
|
|||||||
_this.inc = val;
|
_this.inc = val;
|
||||||
_this.button.value = _this.inc;
|
_this.button.value = _this.inc;
|
||||||
_this.setValue(_this.inc);
|
_this.setValue(_this.inc);
|
||||||
|
// possibly push to an array here so that
|
||||||
|
// we have a record of "defined" / "presets"
|
||||||
|
// ????
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -8,27 +8,26 @@ var StringController = function() {
|
|||||||
|
|
||||||
var input = document.createElement('input');
|
var input = document.createElement('input');
|
||||||
|
|
||||||
input.setAttribute('value', this.object[this.propertyName]);
|
var initialValue = this.getValue();
|
||||||
|
|
||||||
|
input.setAttribute('value', initialValue);
|
||||||
this.domElement.addEventListener('mouseup', function() {
|
this.domElement.addEventListener('mouseup', function() {
|
||||||
input.focus();
|
input.focus();
|
||||||
input.select();
|
input.select();
|
||||||
}, false);
|
}, false);
|
||||||
|
|
||||||
input.addEventListener('keyup', function() {
|
input.addEventListener('keyup', function() {
|
||||||
console.log(input.value);
|
_this.setValue(input.value);
|
||||||
_this.setValue(input.value);
|
|
||||||
}, false);
|
}, false);
|
||||||
|
|
||||||
this.domElement.appendChild(input);
|
input.onblur = function(e) {
|
||||||
|
if(_this.getValue() == '') {
|
||||||
input.onfocus = function(e) {
|
_this.setValue(initialValue);
|
||||||
if(_this.contents == _this.object[_this.propertyName]) {
|
this.value = initialValue;
|
||||||
contents = "";
|
|
||||||
_this.input.setAttribute('value', contents);
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
input.onblur = function(e) {
|
|
||||||
};
|
this.domElement.appendChild(input);
|
||||||
};
|
};
|
||||||
StringController.prototype = new Controller();
|
StringController.prototype = new Controller();
|
||||||
StringController.prototype.constructor = StringController;
|
StringController.prototype.constructor = StringController;
|
Loading…
Reference in New Issue
Block a user