cancel
Showing results for 
Search instead for 
Did you mean: 

force update of scrollbar in scrollableContainer

mip
Associate II

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?

15 REPLIES 15
LouisB
ST Employee

Hello @mip,

Have you tried to do : 

scrollableContainer1.invalidate();

BR, 

Louis BOUDO
ST Software Engineer | TouchGFX
mip
Associate II

Hello @LouisB 

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

Mikkel

LouisB
ST Employee

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 BOUDO
ST Software Engineer | TouchGFX
mip
Associate II

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.

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

Louis BOUDO
ST Software Engineer | TouchGFX
mip
Associate II

I have:

    scrollableContainer1.setScrollbarsPermanentlyVisible();

 

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

Louis BOUDO
ST Software Engineer | TouchGFX
mip
Associate II

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

LouisB
ST Employee

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 BOUDO
ST Software Engineer | TouchGFX