Hello,
try following:
Step 1: I don't know why there are two properties in the class for the autoobject (TheClass) necessary. To store the winter/summer season it would be sufficient to have one property only. This property has not necessarily to be of string type. It can also be a bool type: false is winter, true is summer, etc. In the first step you could delete the second property from the class.
Step 2: Open the onset method associated to the property for editing by double clicking on it. The implementation of the method appears in Code Editor. Ensure the implementation ends with the line notifyobservers ... as shown below:
Step 3: Add a 'Property Observer' to the button component.
Step 4: The Property Observer contains per default an onEvent slot method. Double click on the slot method to open it. The implementation of the method appears in Code Editor. Implement the method with code to update the text displayed in the button with the current value of the autoobject. For example:
Step 5: Connect the Property Observer with the property of the autoobject. For example:
Step 6: To get the initial value for the displayed text, you can implement in the button component the Init method. Within the init method execute following code. This will trigger an invocation of onEvent just in the moment when the button is instantiated:
The steps 1..6 implement an automatism to update the text displayed in the button each time the property Season in the autoobject changes.
Step 7: Switch to the component implementing the list.
Step 8: Add Property Observer to the component (similar to step 3).
Step 9: Edit the associated onEvent method. The implementation should adjust the scroll position of the list so that the item corresponding to the value in the autoobject is centered in the list. Following could be the implementation:
Step 10: To get initial adjustment of the scroll position, you can implement in the list component the Init method as explained in step 6.
Step 11: Analog to step 5 connect the Property Observer with the property in the autoobject.
The steps 7..11 implement an automatism to update the list scroll position each time the property Season in the autoobject changes. What is still missing is the modification of the property in the autoobject after the user made a selection in the list. According to your description the list component has two buttons X and V. Pressing V should store the selected value in the autoobject.
Step 12: Assuming there is a method triggered by the V button, open the method for editing and implement following code:
For more details concerning this approach see Model View Controller programming paradigm, Outlet properties and Notifications and Observer.
Please note also the section Lifetime of an autoobject. It explains that autoobjects may be discarded if not used. This will have the effect of the value stored in the autoobject being discarded too. If your application does not use (does not reference) the autoobject permanently, you can add a variable to Application component, declarae the variable with type object and assign the autoobject to this variable. This will result in a strong reference to the object and prevent its destruction.
I hope it helps you further
Best regards
Paul Banach