2011-04-18 21:13:15 +00:00
|
|
|
DAT.GUI.ControllerString = function() {
|
2011-01-29 02:25:48 +00:00
|
|
|
|
2011-04-18 19:06:19 +00:00
|
|
|
this.type = "string";
|
2011-02-10 20:50:57 +00:00
|
|
|
|
2011-04-18 19:06:19 +00:00
|
|
|
var _this = this;
|
|
|
|
DAT.GUI.Controller.apply(this, arguments);
|
2011-02-10 20:50:57 +00:00
|
|
|
|
2011-04-18 19:06:19 +00:00
|
|
|
var input = document.createElement('input');
|
2011-02-10 20:50:57 +00:00
|
|
|
|
2011-04-18 19:06:19 +00:00
|
|
|
var initialValue = this.getValue();
|
2011-02-10 20:50:57 +00:00
|
|
|
|
2011-04-18 19:06:19 +00:00
|
|
|
input.setAttribute('value', initialValue);
|
|
|
|
input.setAttribute('spellcheck', 'false');
|
2011-02-10 20:50:57 +00:00
|
|
|
|
2011-04-18 19:06:19 +00:00
|
|
|
this.domElement.addEventListener('mouseup', function() {
|
|
|
|
input.focus();
|
|
|
|
input.select();
|
|
|
|
}, false);
|
2011-02-10 20:50:57 +00:00
|
|
|
|
2011-04-18 19:06:19 +00:00
|
|
|
// TODO: getting messed up on ctrl a
|
|
|
|
input.addEventListener('keyup', function(e) {
|
|
|
|
if (e.keyCode == 13 && _this.finishChangeFunction != null) {
|
|
|
|
_this.finishChangeFunction.call(this, _this.getValue());
|
|
|
|
}
|
|
|
|
_this.setValue(input.value);
|
|
|
|
}, false);
|
2011-02-10 20:50:57 +00:00
|
|
|
|
2011-04-18 19:06:19 +00:00
|
|
|
input.addEventListener('blur', function() {
|
|
|
|
if (_this.finishChangeFunction != null) {
|
|
|
|
_this.finishChangeFunction.call(this, _this.getValue());
|
|
|
|
}
|
|
|
|
}, false);
|
2011-02-10 20:50:57 +00:00
|
|
|
|
2011-04-18 19:06:19 +00:00
|
|
|
this.updateDisplay = function() {
|
|
|
|
input.value = _this.getValue();
|
|
|
|
};
|
2011-02-10 20:50:57 +00:00
|
|
|
|
2011-04-18 19:06:19 +00:00
|
|
|
this.options = function() {
|
|
|
|
_this.domElement.removeChild(input);
|
|
|
|
return DAT.GUI.Controller.prototype.options.apply(this, arguments);
|
|
|
|
};
|
2011-02-10 20:50:57 +00:00
|
|
|
|
2011-04-18 19:06:19 +00:00
|
|
|
this.domElement.appendChild(input);
|
2011-02-10 20:50:57 +00:00
|
|
|
|
2011-01-25 08:22:04 +00:00
|
|
|
};
|
2011-01-29 04:28:12 +00:00
|
|
|
|
2011-04-18 21:13:15 +00:00
|
|
|
DAT.GUI.extendController(DAT.GUI.ControllerString);
|