Skip to main content
Associate
February 26, 2025
Question

Assign a different Scrollbar width to a scrollableContainer

  • February 26, 2025
  • 4 replies
  • 629 views

I am working with TouchGFX Designer 4.24.2
If I assign a different Scrollbar width to a scrollableContainer in     Screen1view::setupScreen()
after or before the command     Screen1ViewBase::setup();

      scrollableContainerMainMenu.setScrollbarWidt(50);
      scrollableContainerMainMenu.invalidate();

 

the scrollbar is only 50 pixels wide after you click into the ScrollableContainer.
What do you have to do so that it is displayed in the correct width from the start?

4 replies

GaetanGodart
Technical Moderator
February 28, 2025

Hello @User2025 and welcome to the community!

 

Simply call 

scrollableContainerName.childGeometryChanged();

and your new scrollbar width will be shown before you even touch the scrollableContainer.

 

If this comment answer your question, I invite you to select it as "best answer".

 

Regards,

GaetanGodart
Technical Moderator
March 13, 2025

Hello @User2025 ,

 

Have you been able to solve your issue?

 

Regards,

User2025Author
Associate
March 25, 2025

Hello GaetanGodart,

thank you very much for your help. It works well.

I try it with

scrollableContainerMainMenu.doScroll(0, 0);

but this only works with Y values not equal to 0 (e.g. -1).

scrollableContainerMainMenu.doScroll(0, -1);

 

Regards,

GaetanGodart
Technical Moderator
March 25, 2025

Hello @User2025 ,

 

This seems to be a completely different question here.

scrollableContainerMainMenu.doScroll(x, y) is used to scroll the container up/down and left/right.

Therefore, using 0 as a value will scroll 0 pixels.

So I don't see what is the issue here.

 

Regards,

User2025Author
Associate
April 1, 2025

Hello Gaetan Godart,
I had used the command scrollableContainer.doScroll(0, -1) as a substitute to force a redraw of the scrollbar, but did not realize that (0,0) corresponds to the actual state at the start time and is therefore nonsense.
Many thanks for your help.

GaetanGodart
Technical Moderator
April 1, 2025

My pleasure @User2025 !

 

Can you select the comment that helped you the most as "best answer"?

 

Regards,