2025-08-20 6:52 AM
I'm trying to create a long vertical menu that can be configured for a different number of items. I have managed to get a working implementation with a single issue.
I would like to be able to select which item in the list is shown when the menu is loaded. For example, given a list of 30 items, I would like to go to Item 10 if it were the last item selected previously.
What I have tried:
Custom container scroll list with a custom container menu item. The scroll list is stored in a scrollable container to provide a scrollbar. For the scroll list to work with a long list, I have made the scroll list container's height long enough to fit 30 items within the designer. To force the list display to start from a specific point, I have tried animateToItem()
which has no effect.
listMenuView.cpp
what is this the correct way to implement this behavior?
Solved! Go to Solution.
2025-08-20 8:39 AM - edited 2025-08-20 8:39 AM
Hi Eddie
If I understand right your explanation about your configuration, you should scroll the scrollable container instead of scrollList.
Something like this:
scrollableContainer1.doScroll(0,(scrollList1ListItems[0].getHeight()*n)*-1); // n = index of first shown item
You can check the doScroll function parameters here
https://support.touchgfx.com/docs/api/classes/classtouchgfx_1_1_scrollable_container
Hope this helps.
Br JTP
2025-08-20 8:39 AM - edited 2025-08-20 8:39 AM
Hi Eddie
If I understand right your explanation about your configuration, you should scroll the scrollable container instead of scrollList.
Something like this:
scrollableContainer1.doScroll(0,(scrollList1ListItems[0].getHeight()*n)*-1); // n = index of first shown item
You can check the doScroll function parameters here
https://support.touchgfx.com/docs/api/classes/classtouchgfx_1_1_scrollable_container
Hope this helps.
Br JTP
2025-08-20 8:47 AM
Thanks a lot, JTP1! That worked. Much appreciated
Eddie