cancel
Showing results for 
Search instead for 
Did you mean: 

The confusion of update strategy of scrolledXY in scrollableContainer.

Wrend.1
Senior

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?

1 ACCEPTED SOLUTION

Accepted Solutions
Alexandre RENOUX
Principal

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

View solution in original post

2 REPLIES 2
Alexandre RENOUX
Principal

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

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.