Skip to main content
prathima
Associate III
February 28, 2020
Solved

swiping and scrolling

  • February 28, 2020
  • 3 replies
  • 2109 views

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..

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

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

3 replies

Alexandre RENOUX
Alexandre RENOUXBest answer
Visitor II
March 5, 2020

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

RMoli.3
Associate III
January 23, 2023

I can confirm this is working perfectly with 0 changes

prathima
prathimaAuthor
Associate III
March 9, 2020

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
Visitor II
March 9, 2020

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