How do I override a variable from a superclass programmatically?

Scotte Meredith spomacguy at gmail.com
Wed Sep 25 18:19:59 UTC 2024


Hi, Doug --

I'm working on my oCSS object that will re-skin a window with a particular theme. (You know about this; others may not.) 

It does it on-the-fly for most windows, but in the case of very complex window,s it can be a little slow opening the window each time (up to 0.8 seconds on some of my tests). So I have a feature we've been using for some time to "compile" the window. Once it opens it, it writes the changes in all the field properties back to the library and sets a variable indicating it has already been compiled and so not run the theme changes again. 

I have added a new variable to the superclass called inColorTheme. So each of the child classes inherits this variable. I want a way to override that variable in the windows to be able to store back with the window an $ivardefs.inColorTheme.$objinitval so that the window holds the theme it was last compiled with. (I don't want to have to manually update each window and override the variable manually.) 

If later the color theme changes, I ask the window what theme it was compiled with and if it is different from the new theme, it will recompile with the new theme and then save the window with the theme value back to disk.

You can distinguish between the value in the superclass by using $cinst.inColorTheme to get the overridden value.

There were a couple of things I found in the docs about $isinherited.$canassign and $isinherited.$assign that seemed to imply it would work, but I'm not having much luck.

If there is not a way to do it like this, I may put the value of the theme into $userinfo as a name/value pair before saving the class.


HTH.


Scotte Meredith
spomacguy at gmail.com
509/998-0991




> On Sep 25, 2024, at 10:59 AM, Doug Easterbrook <doug at artsman.com> wrote:
> 
> at the risk of not really understanding.
> 
> is this an inherited variable you want to over-ride?    i,e,   the superclass has ‘iList’ and the subclass has ‘iList’ inherited from the main window.
> 
> I’ve never found an need to do this as overriding the inherited variable always has led to debugging grief.  Far better to declare a variable and copy it value if you don’t want to touch the superlass value
> 
> 
> or is this just a small subwidow (such as a popup) that refers to the main window’s variables?   
> 
> In such as case I always refer to the main window variables as $cwind.theVar and never declare it locally.     Or I declare a reference to the main window and reference variables that way with a getter/setter
> 
> So, if I want a copy of the variable that I play with internally, I copy it as needed and save it as needed.
> 
> 
> 
> 
> In the latter situation (ie. the variable is not inherited), my thoughts are that you are asking for a developer support issue if you use the same name for the variable because somebody will change things on yoy, whether you want to or not.
> 
> there is the old adage, blue code is good code and black code is bad code.   Same with instance variables.   Blue variables are good variables black variables are local only..  and should not be able to be inherited.   because that would be my first inclination when editing code as I know it causes some elements of debugging grief
> if they are not inherited.
> 
> 
> 
> so, thats standing on a soap box….    maybe you could explain the use case or why you need to use a variable of the same name (if not inherited).
> 
> 
> 
> Doug Easterbrook
> Arts Management Systems Ltd.
> mailto:doug at artsman.com
> http://www.artsman.com
> Phone (403) 650-1978
> 
>> On Sep 25, 2024, at 10:04 AM, Scotte Meredith <spomacguy at gmail.com> wrote:
>> 
>> I have a superclass window. I've added a new instance variable. 
>> 
>> In the child windows, I want to override the instance variable programmatically. I can do this from the context menu in the instance variable list pane by right-clicking on the variable and selecting "Override Variable". 
>> 
>> How do I do this programmatically?
>> 
>> 
>> Scotte Meredith
>> spomacguy at gmail.com
>> 509/998-0991
>> 
>> 
>> 
>> 
>> _____________________________________________________________
>> Manage your list subscriptions at https://lists.omnis-dev.com
>> Start a new message -> mailto:omnisdev-en at lists.omnis-dev.com 
> 



More information about the omnisdev-en mailing list