2020-09-27 03:04 AM
I have a ScrollList, configed as not circular, snapping enabled. After scroll finished, I want to know which item is the first visible in window.
2020-10-13 11:40 PM
Hello,
I don't understand what you really want to achieve.
But the function
void Screen1View::scrollListUpdateItem(imageContainer& item, int16_t itemIndex) is called by the base view each time an element in the scroll list is updated. That means that every time a element is on the verge of being displayed on the screen this function is called to update the items.
Regarding the overall index you might be looking for. A scrollList is tricky because it uses a List that is only the size of the max number of items you can display at once on the display.
If you take the ScrollList and ScrollWheel Example you will see this list in the generated Screen1ViewBase.hpp
touchgfx::DrawableListItems<imageContainer, 5> scrollListListItems;
So the list is 5 items large even though the total amount of items is more than that. This makes having a correct index tricky. Instead you could just get the instance of the item in question thanks to the function scrollListUpdateItem(imageContainer& item, int16_t itemIndex).
I don't know what you are trying to do so it's hard to tell.
But in many cases, I recommend not using ScrollList and use instead a ListLayout inside a Scrollable container because it is much easier to manipulate the items in this configuration.
/Alexandre