mirror of
https://github.com/dataarts/dat.gui.git
synced 2024-12-12 04:08:27 +00:00
Functional boolean, function and string controllers.
This commit is contained in:
parent
0554c7ea98
commit
723dbadb36
@ -13,7 +13,7 @@ var BooleanController = function() {
|
||||
}, false);
|
||||
|
||||
input.addEventListener('mouseup', function(e) {
|
||||
input.checked = !input.checked;
|
||||
input.checked = !input.checked; // counteracts default.
|
||||
}, false);
|
||||
|
||||
this.domElement.style.cursor = 'pointer';
|
||||
|
@ -1,8 +1,13 @@
|
||||
var FunctionController = function() {
|
||||
this.type = "function";
|
||||
var _this = this;
|
||||
Controller.apply(this, arguments);
|
||||
var input = document.createElement('input');
|
||||
input.setAttribute('type', 'submit');
|
||||
this.domElement.addEventListener('click', function() {
|
||||
_this.object[_this.propertyName].call(_this.object);
|
||||
}, false);
|
||||
this.domElement.style.cursor = "pointer";
|
||||
this.domElement.appendChild(input);
|
||||
};
|
||||
FunctionController.prototype = new Controller();
|
||||
|
@ -19,5 +19,12 @@ var Controller = function() {
|
||||
this.setName(this.propertyName);
|
||||
this.domElement.appendChild(this.propertyNameElement);
|
||||
|
||||
makeUnselectable(this.domElement);
|
||||
|
||||
function makeUnselectable(elem) {
|
||||
elem.onselectstart = function() { return false; };
|
||||
elem.style.MozUserSelect = "none";
|
||||
elem.style.KhtmlUserSelect = "none";
|
||||
elem.unselectable = "on";
|
||||
}
|
||||
};
|
@ -9,8 +9,9 @@ var StringController = function() {
|
||||
var input = document.createElement('input');
|
||||
|
||||
input.setAttribute('value', this.object[this.propertyName]);
|
||||
this.domElement.addEventListener('mouseover', function() {
|
||||
this.domElement.addEventListener('mouseup', function() {
|
||||
input.focus();
|
||||
input.select();
|
||||
}, false);
|
||||
|
||||
input.addEventListener('keyup', function() {
|
||||
|
Loading…
Reference in New Issue
Block a user