Skip to main content
BParh.1
Senior III
November 16, 2021
Question

How to move scrollbar automatically to the selected radio button?

  • November 16, 2021
  • 1 reply
  • 1275 views

Assume I have a scrollable container widget containing several radio buttons. There are many radio buttons that user has to scroll down to see the last radio button.

But assume in application where user need to go to the last chosen radio button that is on bottom, how to automatically scroll down so that it is directly visible to user instead of asking user to scrolldown by himself?

This topic has been closed for replies.

1 reply

Yoann KLEIN
ST Employee
February 21, 2022

Hello @BParh.1​ ,

The ScrollableContainer class implements the doScroll(int deltaX, int deltaY) method, which allows you to programmatically scroll the items vertically and/or horizontally in your widget.

To achieve what you want, you can for example add a Custom Container filled with radio buttons inside your ScrollableContainer widget.

Then, just call scrollableContainer.doScroll(0,customContainer.getHeight()) if you want to scroll the entire widget down and display the last element of your list, or scrollableContainer.doScroll(0, -customContainer.getHeight()) if you want to scroll the container up and display the first element of your list.

I will also attach to this post a project that implements those functionalities.

Hope that this helped you,

/Yoann

Yoann KLEINST Software Developer | TouchGFX