cancel
Showing results for 
Search instead for 
Did you mean: 

How to move scrollbar automatically to the selected radio button?

BParh.1
Senior III

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?

1 REPLY 1
Yoann KLEIN
ST Employee

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 KLEIN
ST Software Developer | TouchGFX