Skip to main content
Associate II
August 14, 2025
Question

force update of scrollbar in scrollableContainer

  • August 14, 2025
  • 11 replies
  • 1045 views

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?

11 replies

ST Employee
August 18, 2025

Hello @mip,

Have you tried to do : 

scrollableContainer1.invalidate();

BR, 

mipAuthor
Associate II
August 18, 2025

Hello @LouisB 

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

Mikkel

ST Employee
August 18, 2025

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 ?

mipAuthor
Associate II
August 18, 2025

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
August 18, 2025

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

mipAuthor
Associate II
August 18, 2025

I have:

 scrollableContainer1.setScrollbarsPermanentlyVisible();

 

ST Employee
August 18, 2025

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

mipAuthor
Associate II
August 19, 2025

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

ST Employee
August 19, 2025

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.

mipAuthor
Associate II
August 19, 2025

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

	scrollableContainer1.invalidateScrollbars();

is called, but the scrollbars are not consistently updating.

ST Employee
August 19, 2025

Ok, can you send the project by private message ?

mipAuthor
Associate II
August 20, 2025

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
August 20, 2025

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

Graduate II
August 21, 2025

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
February 6, 2026

Hi mip,

did you fix your problem? 

I am having the exact same behaviour as you described. 

mipAuthor
Associate II
February 6, 2026

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
February 6, 2026

Hi,
Could you please try this for your project?

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