2025-12-01 2:07 AM - edited 2025-12-01 2:09 AM
I have the need to access items of a scroll wheel that are not visible on the screen (but that are already initialized)
For instance, I have a scroll wheel with each items a toggle button.
With the ScrollUpdateItem I'm able to set the correct index to the item with
ScrollUpdateItem(alarmsItem& item, int16_t itemIndex)
{ item.setIndex(itemIndex)where setIndex is a function that set the index in the item
Now, this works but, I've got the issue when it comes to the callback of each toggle.
For instance, once a callback is called, I need to process items different from the one selected so, I need to access the SelectorScrollListItems
For some reason, despite setting SelectorScroll.setNumberOfItems(6); I'm seeing TouchGFX generating touchgfx::DrawableListItems<alarmsItem, 5> SelectorScrollListItems; so, when I try to access SelectorScrollListItems[5] I'm seeing the call to the assert
TYPE& operator[](int index)
{
assert(index >= 0 && index < SIZE);
return element[index];
}why is that?
How do I fix it?
PS. TouchGFX Designer has the correct number of items set as well
2025-12-01 2:18 AM - edited 2025-12-01 3:10 AM
I think, ultimately, the code generated by TouchGFX Designer is bugged and/or wrong. If I set a numberOfItems in the designer, the corrispondent
touchgfx::DrawableListItems<myItem, numberOfItems>should reflect it. Instead, it is generate with a fixed value
touchgfx::DrawableListItems<myItem, 5>and in the SetupScreen it got initialized wrongly
for (int i = 0; i < mySelectorScrollListItems.getNumberOfDrawables(); i++)
{
mySelectorScrollListItems[i].initialize();
}@JohanAstrup @Osman SOYKURT @LouisB
Your example shows different sizes in the Base hpp that can't be reporduced with the current version of TouchGFX Designer 4.26 https://support.touchgfx.com/docs/development/ui-development/ui-components/containers/scroll-wheel
touchgfx::DrawableListItems<CustomContainer1, 6> scrollWheel1ListItems;
touchgfx::DrawableListItems<CustomContainer2, 2> scrollWheel1SelectedListItems;This seems to be a 2 years old issue https://community.st.com/t5/stm32-mcus-touchgfx-and-gui/touchgfx-support-needed-adding-more-than-6-elements-to-a-scroll/td-p/52563
I've also noticed that the array containing the items (ListItems) is a circular one. So when a new item is shown on the screen and the 5 items of the array are full, it overwrite the one at index 0
2025-12-01 4:24 AM
It's been a while since I worked with TouchGFX, but I think I can help with this explanation:
The scroll wheel and similar lists only generate as many graphic objects (items) as actually fit in the scroll wheel area (or one more). When scrolling, the “pushed out” items are then recycled and pushed back into the image on the other side with new content using ScrollUpdateItem(alarmsItem& item, int16_t itemIndex). So you have to store information elsewhere (in your own data array) and transfer it to the objects in the ScrollUpdateItem() callback.