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.getValue = function() {
|
||||
return this.object[this.propertyName];
|
||||
}
|
||||
|
||||
this.domElement = document.createElement('div');
|
||||
this.domElement.setAttribute('class', 'guidat-controller ' + this.type);
|
||||
|
||||
|
@ -9,7 +9,7 @@ var NumberController = function() {
|
||||
var _this = this;
|
||||
|
||||
this.isClicked = false;
|
||||
this.py = this.y = 0;
|
||||
this.py = this.y = this.initialValue = this.object[this.propertyName];
|
||||
this.inc = 0;
|
||||
|
||||
// Get min and max
|
||||
@ -30,7 +30,7 @@ var NumberController = function() {
|
||||
|
||||
var val = parseFloat(_this.button.value);
|
||||
if(isNaN(val)) {
|
||||
_this.inc = 0;
|
||||
_this.inc = _this.initialValue;
|
||||
} else {
|
||||
_this.inc = val;
|
||||
}
|
||||
@ -72,6 +72,9 @@ var NumberController = function() {
|
||||
_this.inc = val;
|
||||
_this.button.value = _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');
|
||||
|
||||
input.setAttribute('value', this.object[this.propertyName]);
|
||||
var initialValue = this.getValue();
|
||||
|
||||
input.setAttribute('value', initialValue);
|
||||
this.domElement.addEventListener('mouseup', function() {
|
||||
input.focus();
|
||||
input.select();
|
||||
}, false);
|
||||
|
||||
input.addEventListener('keyup', function() {
|
||||
console.log(input.value);
|
||||
_this.setValue(input.value);
|
||||
}, false);
|
||||
|
||||
this.domElement.appendChild(input);
|
||||
|
||||
input.onfocus = function(e) {
|
||||
if(_this.contents == _this.object[_this.propertyName]) {
|
||||
contents = "";
|
||||
_this.input.setAttribute('value', contents);
|
||||
input.onblur = function(e) {
|
||||
if(_this.getValue() == '') {
|
||||
_this.setValue(initialValue);
|
||||
this.value = initialValue;
|
||||
}
|
||||
};
|
||||
input.onblur = function(e) {
|
||||
};
|
||||
|
||||
this.domElement.appendChild(input);
|
||||
};
|
||||
StringController.prototype = new Controller();
|
||||
StringController.prototype.constructor = StringController;
|
Loading…
Reference in New Issue
Block a user