Check for getter and setter methods of direct access fails

This commit is contained in:
Seth Samuel 2011-06-16 12:24:23 -07:00
parent f5ef4a374f
commit 1fd9084574
3 changed files with 12 additions and 5 deletions

View File

@ -134,12 +134,12 @@
<ul>
<li>
<a href='https://github.com/dataarts/dat.gui/raw/build/DAT.GUI.min.js'><strong>Download the minified source</strong></a>
<small id='buildsizemin'>[19.5kb]
<small id='buildsizemin'>[19.6kb]
</small>
</li>
<li>
<a href='https://github.com/dataarts/dat.gui/raw/build/DAT.GUI.js'><strong>Download the uncompressed source</strong></a>
<small id='buildsize'>[33.6kb]
<small id='buildsize'>[33.8kb]
</small>
</li>

View File

@ -42,7 +42,13 @@ DAT.GUI.Controller.prototype.unlisten = function() {
};
DAT.GUI.Controller.prototype.setValue = function(n) {
this.object[this.propertyName] = n;
if(this.object[this.propertyName]){
this.object[this.propertyName] = n;
}else{
var o = new Object();
o[this.propertyName] = n;
this.object.set(o);
}
if (this.changeFunction != null) {
this.changeFunction.call(this, n);
}
@ -51,7 +57,8 @@ DAT.GUI.Controller.prototype.setValue = function(n) {
};
DAT.GUI.Controller.prototype.getValue = function() {
return this.object[this.propertyName];
var val = this.object[this.propertyName] || this.object.get(this.propertyName);
return val;
};
DAT.GUI.Controller.prototype.updateDisplay = function() {

View File

@ -306,7 +306,7 @@ DAT.GUI = function(parameters) {
// return;
}
var value = object[propertyName];
var value = object[propertyName] || (object.get && object.get(propertyName));
// Does this value exist? Is it accessible?
if (value == undefined) {