On property changed

  • I'm trying to figure out how to change all instance properties to the initial(instance 1) settings. I want to make sure that the properties remain the same across all instances. Here is what I have at the moment, any ideas?

    this setting sets the values to an [object][object] error.

    IDEInstance.prototype.OnPropertyChanged = function(property_name)

    {

    this.properties["App ID"] = property_list[0];

    this.properties["Language"] = property_list[1];

    }

    To better explain, I effectively only want to allow users to change the values on the first instance. I'd prefer to set the read only flag for the rest, but I can't seem to wrap my mind around it at this moment.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • try this

    var pluginInstances = {}; //This will store your plugin instances.
    var pluginInstancesIndex = 0; // A Simple index counter
    
    function IDEInstance(instance, type)
    {
        assert2(this instanceof arguments.callee, "Constructor called as a function");
    
        this.instance = instance;
        this.type = type;
        this.properties = {};
    
        pluginInstances[pluginInstancesIndex++] = this.properties; // Add this to store the new properties instances to the colleciton
    
        for (var i = 0; i < property_list.length; i++) 
            this.properties[property_list[i].name] = property_list[i].initial_value;
    
    }
    
    IDEInstance.prototype.OnPropertyChanged = function(property_name)
    {
        //When the property changes get the val
        var val = this.properties[property_name]
        for(var i in pluginInstances){
                //Then loop through the instances and apply it to all
    	    pluginInstances[i][property_name] = val;
        }
    }
    
    [/code:36ng7frt]
  • That looks pretty elegant and simple. Thanks I will try that. Any idea how to set the .readonly flag?

  • Not really.. I don't have much experience with plugin properties yet. But I don't think properties have read-only setting (could be wrong)... but it would kind of defeat the purpose i think of something the user is intended to be able to change that is set to read only.

  • Yeah, it's listed in the manual, anywho thanks much

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)