What is the trick to get the property values correctly shown when you drop your control on the IDE window? Currently, zero values for integers are shown, color properties are in black, pop-down is set to top (zero value), font is empty, font size is zero, text is zero. The initial values set are much different. Clicking on a pop-down box and choosing zero, triggers the update of all the properties to the initial values set in the plugin. (Font set to System, which translates to Menlo-Regular on osx, and size 11) and so on. On windows font System is set to Verdana and size 8. But what should be done within the plugin when it comes to a user dropping the control on the window.
When a control from a plugin is placed on a layout the initial values come from the superclass - not the instance
There’s a loop that is
find superclass for every property on the instance get the starting value for the property from the super class next
If the super isn’t providing those or doesn’t have them set to the initial default values then the instance will not get them at the outset
Once you touch the instance in the inspector what you’re seeing is the IDE rereading the instance values which you’d set and voila there they are
Does that make sense ?
Actually, it does not make sense when considering that the IDE is reading all the getters and then issues all the setters after the OpenFunction callback. Touching the dropped instance does not make the IDE rereading the instance values as I can prove with debug messages. The IDE knows them already, but is not displaying them.
With respect to “find superclass” it is of course the RectControl. It will give the left, top, bottom, right, the locks, the name. Xojo’s textfield, etc is correctly updated, but not a third-party plugin (can only speak for one plugin, so bear with me), unless I am overlooking something very trivial, but I cannot get my head around it. I guess, I will provide the plugin in its current state, with meaningful log messages, so once someone has time, he or she can look into it.
It is not really urgent, it is not a show-stopper, but I think, it is not right.
The instance superclass IS the class def for the lexer not rect control
SO we read that , and set the initial values for the instance properties from the class def
It looks like you have values on the instance which are NOT whats used initially
Once you touch it the property values on the instance are then used which is why you see things switch
But that initial set up is from the class def and its properties
The plugin does not do anything fancy; If the Editor is loaded, which occurs in the OpenFunction callback, and the plugin is leaving this callback, then the IDE is reading the getters. Because these getters are calling into the editor, the editor provides the default values. In the ConstructorFunction Callback the plugin is providing its own default values, but the IDE is not reading these (unless the editor was not loaded). Whatever discussion we have had, it has been moot. Will tell you later why.
The editor gets the very first set of values from the Superclass not the instance.
I can post the actual code from the IDE. But its basically
get a reference to superclass (this will be your lexing control class)
create an instance
for each property in superclass
set instance property from super class property definition
Note it doesn’t ask the instance about values at all - so whether new instances have values set is really irrelevant at this point.
The property editor then sets up with all the known properties and, since the class definition didn’t supply values, they are all default values. Colors are black, integers are 0 etc exactly as you described.
Once you touch the instance in the inspector or somehow alter it such that the editor has to change a property on the instance the editor then rereads the values from the instance. And this is the behaviour your seeing. It suddenly gets values from the instance and everything is up to date with how you thought you set up the instance.