in GUI Development by

I created a "button" called "settings-item" capable of giving access to a section called "Summer_Winter",

within this I created a vertical list made up of two strings, I would like to ensure that based on the string centered inside the black outline (summer or winter)
add summer or winter instead of the Text label, how could this be done? what logic should I adopt?


1 Answer

0 votes

Hello VonMartello,

without knowing your implementation it is difficult to answer this question. Following could help you:

1. Get the selection from the Vertical List. First information you need is the index of the item displayed in the center of the list. Use following code to query this index:

var int32 inx = VerticalList.GetItemAtPosition( VerticalList.Bounds.center );

Knowing the index, you can estimate the corresponding content. You do this already in the OnLoadItem method. Similarly obtain the content (the string) for the selected item.

2. Update the Sommer-Winter button. I don't know your button implementation. Knowing the text from the selected list item (see step 1) you can assign (?) the text to your button (?).

3. Communication between the button and the Summer_Winter component. Assuming, the Summer_Winter component is presented by the button, then the button can remember this component in its own variable. When the component is dismissed, it uses the variable to ask the component for the selected item (see step 1). Other approach could work in opposite direction. Here, prepare the Summer_Winter component to have a variable or property referring the button. Just before the component is presented, assign to it the corresponding button. The component can so access the button and update (?) its displayed text.

See also the section Implementing component interface.

I Hope it helps you further.

Best regards



My intent was to implement an autoclass where within it I implemented a property of type string with default string winter and another property called season 2 called "summer" by default, 


As for the implementation of the button, it is a simple button to access the winter or summer selection screen, with the string to the right that is to take the value of summer or winter . This button provides access to the section consisting of a vertical list, to which I have associated a SlideTouchHandler to be able to allow summer or winter to be centered in the black border


I thought I could associate two slots and insert them to the touch handler, for example on OnEnd and OnStart by implementing the scrollofset position of the vertical list.
Under the list, I created two buttons with an X and a V, in case the user after selecting one of the two seasons, after clicking on the confirmation button with the (V), the interface should return to the previous section with the updated button with the season inscription



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 paradigmOutlet 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

Thank you very much it helped me to learn more about new functions.

Embedded Wizard Website | Privacy Policy | Imprint