Note that there are some explanatory texts on larger screens.

plurals
  1. POjs events problem
    primarykey
    data
    text
    <p>i want to make a some king of property inspector like any ide. Here is my code (it´s in development)</p> <pre><code>var PropertiesWindow = function(divId, title) { this.propList = new Array(); this.postfix = new Date().getTime(); this.observedObject = null; this.containerDiv = divId; this.propIdSufix = 'prop_'; title = title != undefined ? title : 'Properties'; // create the header element var header = document.createElement('div'); // set same style header.id = 'prop-header'+this.postfix; header.innerHTML = format('&lt;span&gt;{0}&lt;/span&gt;', title); document.getElementById(divId).appendChild(header); this.domElement = document.getElementById(this.containerDiv); // set style }; PropertiesWindow.prototype.propertyValueChanged = function(ev){ if(ev!=null &amp;&amp; this.observedObject!=null){ var propName = ev.target.id.split('_')[0]; this.observedObject[propName] = ev.target.value; } }; PropertiesWindow.prototype.attachProp = function(id, description, editor) { if (this.domElement != null) { var content = '&lt;label style="margin-left:7px;margin-bottom:7px;float:left;"&gt;{0}&lt;/label&gt;&lt;input id="{1}" type="text" style="border: solid 1px #aaaaaa;float:right;margin-right:7px;width: 70px;" /&gt;'; content = format(content, description, id+'_'+this.postfix); var divElement = document.createElement('div'); divElement.id = this.propIdSufix + id; divElement.style.clear = 'both'; divElement.innerHTML = content; this.propList.push(id); this.domElement.appendChild(divElement); document.getElementById(id+'_'+this.postfix).addEventListener('keyup', this.propertyValueChanged, false); } }; PropertiesWindow.prototype.removeProp = function(id) { if (this.domElement != null) { var propId = this.propIdSufix + id; var innerElement = document.getElementById(propId);// this.findProp(propId); if (innerElement != null) this.domElement.removeChild(innerElement); } }; PropertiesWindow.prototype.subscribe = function(obj) { obj.setListener(this); this.observedObject = obj; for ( var propName in obj) { var propElement = document.getElementById(propName+'_'+this.postfix); if (typeof (obj[propName]) != "undefined" &amp;&amp; propElement != null) { propElement.value=obj[propName]; } } }; PropertiesWindow.prototype.update = function(pname,val) { var propElement = document.getElementById(pname+'_'+this.postfix); if(propElement!=null) propElement.value = val; }; </code></pre> <p>i have a problem on method attachProp i have this code <code>document.getElementById(id+'_'+this.postfix).addEventListener('keyup', this.propertyValueChanged, false);</code></p> <p>i defined a method in my object call propertyValueChanged but, when it is fired i can´t no access to the properties of the PropertiesWindow. I understand that i´m in other context. Is there any maner to access to PropertiesWindow´s properties??</p> <p>look:</p> <pre><code>if(ev!=null &amp;&amp; this.observedObject!=null){ var propName = ev.target.id.split('_')[0]; this.observedObject[propName] = ev.target.value; } </code></pre> <p>this.observedObject is undefined</p> <p>Thanks in advance.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload