256 views
in GUI Development by
Good Day to all.

I am trying to add a new item to list on button press. I placed a vertical list but cant seem to change NoOfItems on button press. i am new to embedded wizard and still not very good with property updates and stuff. Can someone please share an example?

1 Answer

0 votes
by

Hello,

it is an easy task. The property is like a variable. You can evaluate and modify it similarly to how you do this in C or Java. The difference to an ordinary variable is, each access to the property can trigger an associated onget or onset operation. In case of the Vertical List, when you assign a new value to the property NoOIfItems, the corresponding onset operation forces the list to perform all necessary updates. So far the technical backgrounds.

Assuming you have the Vertical List and Push Button already existing within a GUI component, then:

1. Add a new slot method to the component. Name it e.g. onButton.

2. Connect the Push Button with the slot method. For this purpose you enter the name of the slot method (e.g. onButton) in the Push Button's property OnActivate:

3. Open the slot method for editing. The method's content (its source code) is now shown in Code Editor.

4. Modify the method in the Code Editor as shown below:

Now, each time the user activates the Push Button, the slot method onButton is executed and the property NoOfItems is incremented. This causes the Vertical List to perform all necessary updates. The new item appears at the end of the list. To test it better, do also following:

5. After selecting the Vertical List change in Inspector its NoOfItems property to the value 0 (zero). With this the list is empty per default:

Now when you start the Prototyper (e.g. by pressing the key F5) you can play with the component. Each time you activate the Push Button, a new item is appended at the end of the list. If you want the list to scroll to the just appended item, you can modify the slot method as follows:

 

I hope it helps you further.

Best regards

Paul Banach

Embedded Wizard Website | Privacy Policy | Imprint

...