cancel
Showing results for 
Search instead for 
Did you mean: 

swiping and scrolling

prathima
Associate II

hello...

I have a swipe container which consist of three pages ..what i have done is i want a scroll wheel in page 2 as screen, so i covered whole screen (page 2) with scroll wheel

but when am doing swipe i can't able to swipe from page 2 to page 3..may i haves scroll wheel entire may be it is not working..is there any solution for this issue...if any please let me know..

thank you..

1 ACCEPTED SOLUTION

Accepted Solutions
Alexandre RENOUX
Principal

If your scroll wheel filling the entire screen is horizontal then it is not possible to distinguish the swipe container and the scroll wheel. However, if the scroll wheel is vertical, then you need to distinguish between horizontal drag and vertical drag as well as clicks on the scroll wheel or outside the scroll wheel.

Here is a example that shows the way I performed this distinction for a project related to a music player with a scroll list (similar behavior as the scroll wheel) and a swipe container.

void MusicPlayerView::handleClickEvent(const ClickEvent& evt)
{
    if (evt.getType() == ClickEvent::PRESSED)
    {
        if(scrollablePlaylistContainer.getAbsoluteRect().intersect(evt.getX(), evt.getY()))
        {
            isPlaylistClicked = true;
        }
    }
    else if (evt.getType() == ClickEvent::RELEASED)
    {
        dragType = NONE;
    }
 
    if(dragType != VERTICAL) //The swipe container should handle the event
    {
        musicPlayerSwipeContainer.handleClickEvent(evt);
    }
    MusicPlayerViewBase::handleClickEvent(evt);
}
 
void MusicPlayerView::handleDragEvent(const DragEvent& evt)
{
    if(isPlaylistClicked)
    {
        isPlaylistClicked = false;
        if(abs(evt.getDeltaY()) < abs(evt.getDeltaX()))
        {
            dragType = HORIZONTAL;
        }
        else
        {
            dragType = VERTICAL;
        }
    }
    else
    {
        if(dragType == HORIZONTAL) //The swipe container should handle the event
        {
            musicPlayerSwipeContainer.handleDragEvent(evt);
        }
        else //The scroll container or the view should handle the event
        {
            MusicPlayerViewBase::handleDragEvent(evt);
        }
    }
}
 
void MusicPlayerView::handleGestureEvent(const GestureEvent& evt)
{
    if(dragType == HORIZONTAL) //The swipe container should handle the event
    {
        musicPlayerSwipeContainer.handleGestureEvent(evt);
    }
    else //The scroll container or the view should handle the event
    {
        MusicPlayerViewBase::handleGestureEvent(evt);
    }
}

/Alexandre

View solution in original post

4 REPLIES 4
Alexandre RENOUX
Principal

If your scroll wheel filling the entire screen is horizontal then it is not possible to distinguish the swipe container and the scroll wheel. However, if the scroll wheel is vertical, then you need to distinguish between horizontal drag and vertical drag as well as clicks on the scroll wheel or outside the scroll wheel.

Here is a example that shows the way I performed this distinction for a project related to a music player with a scroll list (similar behavior as the scroll wheel) and a swipe container.

void MusicPlayerView::handleClickEvent(const ClickEvent& evt)
{
    if (evt.getType() == ClickEvent::PRESSED)
    {
        if(scrollablePlaylistContainer.getAbsoluteRect().intersect(evt.getX(), evt.getY()))
        {
            isPlaylistClicked = true;
        }
    }
    else if (evt.getType() == ClickEvent::RELEASED)
    {
        dragType = NONE;
    }
 
    if(dragType != VERTICAL) //The swipe container should handle the event
    {
        musicPlayerSwipeContainer.handleClickEvent(evt);
    }
    MusicPlayerViewBase::handleClickEvent(evt);
}
 
void MusicPlayerView::handleDragEvent(const DragEvent& evt)
{
    if(isPlaylistClicked)
    {
        isPlaylistClicked = false;
        if(abs(evt.getDeltaY()) < abs(evt.getDeltaX()))
        {
            dragType = HORIZONTAL;
        }
        else
        {
            dragType = VERTICAL;
        }
    }
    else
    {
        if(dragType == HORIZONTAL) //The swipe container should handle the event
        {
            musicPlayerSwipeContainer.handleDragEvent(evt);
        }
        else //The scroll container or the view should handle the event
        {
            MusicPlayerViewBase::handleDragEvent(evt);
        }
    }
}
 
void MusicPlayerView::handleGestureEvent(const GestureEvent& evt)
{
    if(dragType == HORIZONTAL) //The swipe container should handle the event
    {
        musicPlayerSwipeContainer.handleGestureEvent(evt);
    }
    else //The scroll container or the view should handle the event
    {
        MusicPlayerViewBase::handleGestureEvent(evt);
    }
}

/Alexandre

prathima
Associate II

THANK YOU...

Can you please provide the .h file also.... whatever you have provided to me is .c file and i can't able to understand what is musicPlayerSwipeContainer...and what is scrollablePlaylistContainer this i

is i think your widget names in the designer please give me proper details on this....

thank you

Alexandre RENOUX
Principal

As the names state, musicPlayerSwipeContainer is a SwipeContainer and scrollablePlaylistContainer is a ScrollableContainer.

touchgfx::SwipeContainer musicPlayerSwipeContainer;
touchgfx::ScrollableContainer scrollablePlaylistContainer;

Giving you the hpp files would not help you as there is a lot of other things coded and it would be irrelevant. I gave you all you need to implement your own swipe container and scrollWheel or ScrollableContainer to be able to make your own application.

/Alexandre

I can confirm this is working perfectly with 0 changes