cancel
Showing results for 
Search instead for 
Did you mean: 

Can a swipe container be triggered to change programmatically?

Bob Bailey
Senior

Either from the code, or a screen button interaction? I added a swipe container to my project and it appears to be working, but I will be using a resistive touch screen and I don't know yet how well it will interpret swipes. I would like it to be able to have both buttons and swipe.

Is there a link to the source for this example: https://www.youtube.com/watch?v=3zAS3WFp4Rs

thanks

4 REPLIES 4
Bob Bailey
Senior

To externally trigger a swipe, do we call void setSelectedPage(uint8_t pageIndex) ? if so we would want/need to know its current index, right?

Also, how do we make the swipe container remember what its current page is? Is there a built in feature for it? Or do we need to (somehow) pass the current page back to the model, and then retrieve it when the page with the container is re-created? I could imagine some of this logic if the page is built programmatically, but the files generated by the designer will be overwritten.

Thanks

Bob

Alexandre RENOUX
Principal

Hello Bob,

It is currently not possible to know the current index by calling a built-in TouchGFX function. However, it is relatively easy to code its own index handling. For that you need a variable that will take a value between 0 and NB_PAGES-1. The index 0 corresponds to the page at the bottom in the TouchGFX Designer Screens handling (where you can specify if one widget should be on top of another).

Changing pages does not require saving the index in the Model. As long as you only have one screen with a swipe container, you will never lose the index value that you update when changing page.

Calling setSelectedPage(uint8_t pageIndex) will indeed send you to the corresponding page but without any animation.

In order to have an animation left or right to the next page when pressing a button, you must implement your own swipe container based on the one from TouchGFX framework.

/Alexandre

Bob Bailey
Senior

is the source code for the examples available (the above example, or others showing how some of the more complicated transitions and animations are done) ?

Bob

Alexandre RENOUX
Principal

In TouchGFX Designer, you can find several examples as well as demos you can start with. Then if you click on the button Generate code and then if you click on button Browse code, you will be able to see all the generated files. For instance, on the video you can see a game with a bird, this is from the demo called TouchGFX Demo 2.

/Alexandre