Skip to main content
Senior III
April 29, 2025
Solved

allowVerticalDrag() doesn't work on scroll list

  • April 29, 2025
  • 4 replies
  • 1089 views

The same issue has been reported years ago https://community.st.com/t5/stm32-mcus-touchgfx-and-gui/method-allowverticaldrag-in-scroll-list-container-does-not-seem/m-p/169035#M10136

If you create a mySelectorScroll and in the code mySelectorScroll.allowVerticalDrag(false); the scroll list will continue to be scrollable no matter what

Also, accoridng to docs (https://support.touchgfx.com/docs/api/classes/classtouchgfx_1_1_scroll_base#function-allowverticaldrag) it should be OFF by default

 

enableIf true, vertical scrolling is enabled. If false (default), scrolling is disabled.
Best answer by nico23

Hi @GaetanGodart 

I'm using a standard Scroll List, not a Scrollable Container and I feel, according to docs (https://support.touchgfx.com/docs/api/classes/classtouchgfx_1_1_scroll_list) it has not that method.

Also, I'm not setting the height/width dynamically.

The Scroll List uses as items a custom container.

A workaround seems to be settings accelerations to 0

mySelectorScroll.setDragAcceleration(0);
mySelectorScroll.setSwipeAcceleration(0);

 

4 replies

GaetanGodart
Technical Moderator
April 29, 2025

Hello @nico23 ,

 

Can you try to call 

mySelectorScroll.childGeometryChanged();

 

I had a similar question where someone asked why the scrollbar width did not update after he changed it and it solved the issue :

scrollableContainer1.setScrollbarWidth(20);
scrollableContainer1.childGeometryChanged();

Somehow, the scrollbar is a child of the scrollableContainer and therefore need to be updated.

 

If that doesn't work, can you tell me what is "mySelectorScroll"? Is it a standard scrollList or is it a custom container?

 

Regards,

nico23AuthorBest answer
Senior III
April 29, 2025

Hi @GaetanGodart 

I'm using a standard Scroll List, not a Scrollable Container and I feel, according to docs (https://support.touchgfx.com/docs/api/classes/classtouchgfx_1_1_scroll_list) it has not that method.

Also, I'm not setting the height/width dynamically.

The Scroll List uses as items a custom container.

A workaround seems to be settings accelerations to 0

mySelectorScroll.setDragAcceleration(0);
mySelectorScroll.setSwipeAcceleration(0);

 

GaetanGodart
Technical Moderator
April 29, 2025

The scrollList inherit from drawable which have the method childGeometryChanged :

GaetanGodart_0-1745936491548.png

 

Setting the drag speed to 0 indeed prevent any movement, that could be a workaround for you. :)

 

Have you tried to call childGeometryChanged() though?

 

Regards,

nico23Author
Senior III
April 29, 2025

I've called 

mySelectorScroll.childGeometryChanged();
mySelectorScroll.allowVerticalDrag(false);

but the issue persisted

GaetanGodart
Technical Moderator
April 29, 2025

Can you try to put the childGeometryUpdate after the allowVerticalDrag?

 

Regards,

nico23Author
Senior III
April 29, 2025

same, the issue persisted

EDIT: on another note, why the docs says the drag should be OFF by default when it is clearly not? @GaetanGodart 

GMeur
Associate III
July 23, 2025

I want to mention as well that this code in the ScrollBase class :
void ScrollBase::setHorizontal(bool horizontal)
{
allowVerticalDrag(horizontal);
allowHorizontalDrag(!horizontal);
list.setHorizontal(horizontal);
}
is incorrect, the logic should be reverted :
void ScrollBase::setHorizontal(bool horizontal)
{
allowVerticalDrag(!horizontal);
allowHorizontalDrag(horizontal);
list.setHorizontal(horizontal);
}