dat.gui/src/dat/controllers/function.js

31 lines
645 B
JavaScript
Raw Normal View History

DAT.GUI.FunctionController = function() {
2011-04-18 19:06:19 +00:00
this.type = "function";
var _this = this;
DAT.GUI.Controller.apply(this, arguments);
this.domElement.addEventListener('click', function() {
_this.fire();
}, false);
this.domElement.style.cursor = "pointer";
this.propertyNameElement.style.cursor = "pointer";
var fireFunction = null;
this.onFire = function(fnc) {
fireFunction = fnc;
return this;
}
this.fire = function() {
if (fireFunction != null) {
fireFunction.call(this);
}
2011-04-18 19:06:19 +00:00
_this.object[_this.propertyName].call(_this.object);
};
};
DAT.GUI.extendController(DAT.GUI.FunctionController);