Skip to main content
Associate II
Aug 14, 2025 6:50 AM UTC
Question

force update of scrollbar in scrollableContainer

I have made a dynamic menu made with a listLayout with a number of buttons inside a scrollableContainer. When a user push the buttons the listLayout is updated with new content.

I have not been able to have the scrollbar reflect the size of the listLayout after the listLayout is updated. The scrollbar will only update when the user starts scrolling through the new content. Until then it reflect the precious size of the listLayout.

I have tried:

scrollableContainer1.doScroll(0, 180);

Thinking it would have the same effect as the user scrolling the scrollableContainer, but it does not work.

Is there a way to force update of the scrollbar?

19 replies

ST Employee
Aug 18, 2025 9:00 AM UTC

Hello @mip,

Have you tried to do : 

scrollableContainer1.invalidate();

BR, 

Louis BOUDOST Software Engineer | TouchGFX
mipAuthor
Associate II
Aug 18, 2025 9:04 AM UTC

Hello @LouisB 

Yes i invalidate the listLayout and the scrollableContainer every time i add, remove or insert an element.

Mikkel

ST Employee
Aug 18, 2025 9:35 AM UTC

When you say "The scrollbar will only update when the user starts scrolling through the new content", you mean scrolling through the listLayout that is inside the scrollableContainer ?

Louis BOUDOST Software Engineer | TouchGFX
mipAuthor
Associate II
Aug 18, 2025 9:40 AM UTC

yes, the listlayout can contain more menu buttons than can be shown on screen, therefore i have the listLayout inside a scrollableContainer.

After updating the listLayout the scrollBar of the scrollableContainer is not updated. Only when i touch the scrollableContainer, the scrollBar is updated.

ST Employee
Aug 18, 2025 9:47 AM UTC

The scrollbars are also updated if you touch the scrollable container where there's not the listLayout and are you using permanent scrollbars ?

Louis BOUDOST Software Engineer | TouchGFX
mipAuthor
Associate II
Aug 18, 2025 9:54 AM UTC

I have:

 scrollableContainer1.setScrollbarsPermanentlyVisible();

 

ST Employee
Aug 18, 2025 11:06 AM UTC

And are The scrollbars updated if you touch the scrollable container where there's not the listLayout  ?

Louis BOUDOST Software Engineer | TouchGFX
mipAuthor
Associate II
Aug 19, 2025 4:50 AM UTC

I just tested. The scrollbars updates when i touch the scrollabeContainer where there no listLayout.

ST Employee
Aug 19, 2025 7:45 AM UTC

Can you try to edit this file <Project-folder>/touchgfx/framework/include/touchgfx/containers/ScrollableContainer.hpp:

search for : 

 /** Invalidate the scrollbars. */
 void invalidateScrollbars();

 

move it so its a public function and call it to force scrollbar invalidation.

Louis BOUDOST Software Engineer | TouchGFX
mipAuthor
Associate II
Aug 19, 2025 8:13 AM UTC

Unfortunately this is not working. I can see in debugging that

	scrollableContainer1.invalidateScrollbars();

is called, but the scrollbars are not consistently updating.

ST Employee
Aug 19, 2025 9:54 AM UTC

Ok, can you send the project by private message ?

Louis BOUDOST Software Engineer | TouchGFX
mipAuthor
Associate II
Aug 20, 2025 9:38 AM UTC

I can’t send the project to you, as it involves custom hardware and is subject to confidentiality restrictions.

I can make a demonstration of the problem on a development board. I have a STM32U5G9J-DK2. Will that be fine?

 

Mikkel

ST Employee
Aug 20, 2025 1:08 PM UTC

No problem, if you can make that will be nice.

Louis BOUDOST Software Engineer | TouchGFX
Graduate II
Aug 21, 2025 9:31 AM UTC

Hi Mip

You could also try to call doScroll with negative Y delta value, its needed if you want to scroll the content up.

scrollableContainer1.doScroll(0, -180);

Hope this helps.

Br JTP

Explorer II
Feb 6, 2026 7:08 AM UTC

Hi mip,

did you fix your problem? 

I am having the exact same behaviour as you described. 

mipAuthor
Associate II
Feb 6, 2026 9:53 AM UTC

Hi

I have not found a fix.

Please let me know if you solve the issue it in your project.

Mikkel

 

MBrau.7
Associate II
Feb 6, 2026 10:05 AM UTC

Hi,
Could you please try this for your project?

scrollableContainer1.doScroll(0, 1);
scrollableContainer1.invalidate();
scrollableContainer1.doScroll(0, -1);
scrollableContainer.invalidate();