239 views
in GUI Development by

Hello,

I'm looking to implement  a vertical list of settings, different settings differs from the type of variable they manage.

For example, some settings accept a numerical value, other a boolean (switch) or other a string.

I created  a object "SettingItem" to better manage them in the vertical list, wich contains the possible type of a single setting; in the initializtion of the item you can specify the name of the setting and the type of setting it is.

When called the initialization method shows a toggle switch or a string in the right side of the item to show its value based on the nature of the setting.

First question is: How do i manage the showing of the toggle switch or text in the vertical list?  I assumed in the onload method? 

I tried different things (getting the type of varible and accortdingly show/hide the toggle button etc) but,I'm only gettting the string title of the setting and not the parameter on the right.

Second Question, how do i interact with like a toggle button on the vertical list item? I assume on the on tap method? and after invalidate the view of the component to reload it?

Thanks.

 

1 Answer

+1 vote
by

Hello Riccardo,

your approach is correct. Please check following:

1. Ensure the SettingItem component has a method or property to configure its appearance. Possibly it is already the property TypeProperty or the method Initialize()? The idea here: the value of the property should correspond to the current content (switch, text, etc..) of the item. When the property is modified (or the method is invoked), the item should change its content (e.g. show switch and hide text).

2. In the OnLoadItem slot method assign to the above mentioned property (or invoke the Initialize() method) a value corresponding to the desired appearance of the item.

The SettingItem acts in such case as a universal 'item'. This is the unique approach in Embedded Wizard 11 or older. If you are working with Embedded Wizard 12, the list components are more flexible. Instead of using an 'universal' SettingItem, you can specify the item class for each item individually. For user who are working with version 12 (or newer) see the description of OnQueryItemClass in section: Specify the class of the items within the list.

Second Question, how do i interact with like a toggle button on the vertical list item? I assume on the on tap method? and after invalidate the view of the component to reload it?

It depends on your application case. In the simplest case you connect the item with a slot method during OnLoadItem. For example:

itemView.TypeProperty = ... /* value corresponding to switch (?) */
itemView.OnSwitchChanged = Slot_Method_To_Trigger_When_The_Switch_Is_Toggled;

More sophisticated is the approach to connect the switch with a data provider. The data-provider is a property existing usually in a global object. The switch remains in sync-with the value of this property. See also the section Connect the Toggle Button with a data provider explaining this approach in case of the Toggle Button widget. Here again, you establish the connection in the OnLoadItem when the item in question is initialized.

I hope it helps you further.

Best regards

Paul Banach

by

Thanks Paul,

to respond to your points

1. I implemented the initialize method to create an array of SettingItem an directly specify the nature of the item; first parameter is the name of the setting, second the type, so 1 means a boolean, 0 text, etc.

In the TypeSetting onset method i take care of te hide/show of the parameter of the setting: like showing a switch or a text.

If i undestood correctly i have to call the initialize method in the onLoad method  on the itemView var, passing the properties of the SettingItem in the array at the itemNo index?

2. I can connect the outlet of the switch in the SettingItem directly with the property in the item?

Thanks

by

Hello Riccardo,

the list will manage, create and release the item (views) by itself. It is not necessary (even not possible) to manage the list item views in an array. The array should store the data only. It is like a 'data-base'.

I would use two arrays. One array to store the names and second array to store the types. In OnLoadItem slot method use the values from the arrays corresponding to the currently loaded item and assign the values to the currently loaded item. For example:

itemView.TypeProperty = ArrayWithTypes[ itemNo ];
itemView.NameSetting  = ArrayWithNames[ itemNo ];

See also the example project found at the end of the section Force the list to reload items. It uses an array to store some data (counter values).

I can connect the outlet of the switch in the SettingItem directly with the property in the item?

The approach will not make sense, since the array of SettingItem should be avoided as explained above. It's up to you where the properties exist. They can exist locally within the current component or globally in an autoobject.

Best regards

Paul

Ask Embedded Wizard

Welcome to the question and answer site for Embedded Wizard users and UI developers.

Ask your question and receive answers from the Embedded Wizard support team or from other members of the community!

Embedded Wizard Website | Privacy Policy | Imprint

...