Skip to main content
Wrend.1
Associate III
November 4, 2020
Solved

The confusion of update strategy of scrolledXY in scrollableContainer.

  • November 4, 2020
  • 2 replies
  • 894 views

I add a two hardware button to control the up and down scrolling of scrollableContainer(use function "moveChildrenRelative"). But the function "getScrolledY()" can't update according to the scroll action. And I need the ScrolledY to respond to some events.

What should I do to deal with it?

This topic has been closed for replies.
Best answer by Alexandre RENOUX

Hello,

You are right. This is probably something we should change in the near future. I'll tell the team about it.

For the time being, I believe you can simply modify the function manually like as follows :

void ScrollableContainer::moveChildrenRelative(int16_t deltaX, int16_t deltaY)
{
 Drawable* d = firstChild;
 while (d)
 {
 if ((d != &xSlider) && (d != &ySlider))
 {
 if(calledFromOutsideTheClassFlag == true)
 {
 scrolledXDistance += deltaX;
 scrolledYDistance += deltaY;
 }
 d->moveRelative(deltaX, deltaY);
 }
 d = d->getNextSibling();
 }
}

If you want this changes to be taken into account on your board, you need to copy this class in your gui/ folder and use this customClass instead. Unfortunately this will make you unable to use the Designer since it becomes a class the Designer does not know about.

When your question is answered, please close this topic by choosing Select as Best.

/Alexandre

2 replies

Alexandre RENOUX
Alexandre RENOUXBest answer
Visitor II
November 4, 2020

Hello,

You are right. This is probably something we should change in the near future. I'll tell the team about it.

For the time being, I believe you can simply modify the function manually like as follows :

void ScrollableContainer::moveChildrenRelative(int16_t deltaX, int16_t deltaY)
{
 Drawable* d = firstChild;
 while (d)
 {
 if ((d != &xSlider) && (d != &ySlider))
 {
 if(calledFromOutsideTheClassFlag == true)
 {
 scrolledXDistance += deltaX;
 scrolledYDistance += deltaY;
 }
 d->moveRelative(deltaX, deltaY);
 }
 d = d->getNextSibling();
 }
}

If you want this changes to be taken into account on your board, you need to copy this class in your gui/ folder and use this customClass instead. Unfortunately this will make you unable to use the Designer since it becomes a class the Designer does not know about.

When your question is answered, please close this topic by choosing Select as Best.

/Alexandre

Wrend.1
Wrend.1Author
Associate III
November 5, 2020

OK, I got it. And I apply another way to deal with it.

I define a serise of click, drag, gestrue event to realize the similar effect​. And it can bypass this problem.:beaming_face_with_smiling_eyes:

By the way I want to know a standard action from the professionals.