mirror of
https://github.com/dataarts/dat.gui.git
synced 2024-12-12 04:08:27 +00:00
key events added to NumberController
This commit is contained in:
parent
723dbadb36
commit
ee543a4402
@ -10,7 +10,7 @@ var NumberController = function() {
|
||||
|
||||
this.isClicked = false;
|
||||
this.py = this.y = 0;
|
||||
this.inc = 0; // TODO pass argument to inc
|
||||
this.inc = 0;
|
||||
|
||||
// Get min and max
|
||||
(arguments[2] != null) ? this.min = arguments[2] : this.min = null;
|
||||
@ -18,13 +18,25 @@ var NumberController = function() {
|
||||
|
||||
this.button = document.createElement('input');
|
||||
this.button.setAttribute('id', this.propertyName);
|
||||
this.button.setAttribute('type', 'number');
|
||||
|
||||
this.button.setAttribute('type', this.type);
|
||||
this.button.setAttribute('value', this.inc);
|
||||
this.domElement.appendChild(this.button);
|
||||
|
||||
this.button.onmousedown = function(e) {
|
||||
_this.isClicked = true;
|
||||
};
|
||||
this.button.onkeyup = function(e) {
|
||||
|
||||
var val = parseFloat(_this.button.value);
|
||||
if(isNaN(val)) {
|
||||
_this.inc = 0;
|
||||
} else {
|
||||
_this.inc = val;
|
||||
}
|
||||
_this.button.value = _this.inc;
|
||||
_this.setValue(_this.inc);
|
||||
};
|
||||
document.onmouseup = function(e) {
|
||||
_this.isClicked = false;
|
||||
};
|
||||
@ -32,6 +44,8 @@ var NumberController = function() {
|
||||
|
||||
if(_this.isClicked) {
|
||||
|
||||
e.preventDefault();
|
||||
|
||||
_this.py = _this.y;
|
||||
_this.y = e.offsetY;
|
||||
var dy = _this.y - _this.py;
|
||||
@ -49,13 +63,15 @@ var NumberController = function() {
|
||||
_this.inc--;
|
||||
}
|
||||
|
||||
_this.button.setAttribute('value', _this.inc);
|
||||
_this.button.value = _this.inc;
|
||||
_this.setValue(_this.inc);
|
||||
}
|
||||
};
|
||||
|
||||
this.__defineSetter__("position", function(val) {
|
||||
_this.inc = val;
|
||||
_this.button.setAttribute('value', _this.inc);
|
||||
_this.button.value = _this.inc;
|
||||
_this.setValue(_this.inc);
|
||||
});
|
||||
};
|
||||
|
||||
|
@ -20,6 +20,15 @@ var StringController = function() {
|
||||
}, 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) {
|
||||
};
|
||||
};
|
||||
StringController.prototype = new Controller();
|
||||
StringController.prototype.constructor = StringController;
|
Loading…
Reference in New Issue
Block a user