Hello,
if you want to refresh existing GUI components after switching on/off a style, you have to notify all affected GUI components explicitly. Because variants may affect the inheritance of classes, there is no automatic 'update' of already existing objects possible. Already instantiated classes or evaluated expressions involving multi-variant constants or resources will retain their actual value. If you want some value to be updated after a Style has been switched on/off you have to handle this operation explicitly.
How to achieve this?
The application component (the root GUI component of your application) contains a property Styles. This property is in fact a copy of the global built-in variable styles. Modifying the property causes the styles variable also to be modified. Doing this however via the application component will broadcast an event Core::StylesEvent to all GUI components belonging to the view tree. The GUI components can react to this alternation.
To react to such event you have to to override within the affected GUI component its inherited method HandleEvent(). Implement the method with following code:
var Core::StylesEvent event = (Core::StylesEvent)aEvent;
// Is this the 'Styles' event?
if ( event != null )
{
// Assign again the constant containing the unit name
SomeValueDisplay.Unit = Example::SomeConstantWithUnitName;
}
// Give the inherited functionality a chance to process all events
return super( aEvent );
This approach has a problem. If you change the language afterwards, the modification from the HandleEvent() method is discarded. You would thus need to react also to language alternation, which is reported via event Core::LanguageEvent:
var Core::StylesEvent event1 = (Core::StylesEvent)aEvent;
var Core::LanguageEvent event2 = (Core::LanguageEvent)aEvent;
// Is this the 'Styles' or 'Language' event?
if (( event1 != null ) || ( event2 != null ))
{
// Assign again the constant containing the unit name
SomeValueDisplay.Unit = Example::SomeConstantWithUnitName;
}
// Give the inherited functionality a chance to process all events
return super( aEvent );
The appliocation component implements for this purpose also the property Language. Similarly to the above explained Styles property, Language contains a copy of the global built-in variable language. Changing the language via this property will broadcast the Core::LanguageEvent.
This is just one of the possible approaches. You can of course implement your own functionality to notify the affected GUI components after the style has been changed. If you know the GUI components, you can call some methods implemented in the components. Or you use the observer infrastructure. In any case it is necessary to notify the GUI component in order to force their update.
Best regards
Paul Banach