Skip to main content
ferro
Lead
September 24, 2024
Solved

Calling "app ().GotoScreen ()" transition from handleTickEvent () and handleKeyEvent()

  • September 24, 2024
  • 1 reply
  • 679 views

Hi,

Do I need to prevent calling multiple screen transitions from event handlers as illustrated in the following pseudo code ?
Or, once the "application ().gotoOtherScreen ()" is executed in either handleTickEvent () or handleKeyEvent (), there is no way any further handler is called.


I am not sure if there is a way to check for ongoing transition. I thought I saw an API for that somewhere but cannot find it now.
So I call imaginary function "application ().isScreenTransitionInProgress ()".

 

 

// ScreenOne.cpp

void ScreenOne
::handleTickEvent () // override final
{
 if ( ( true == bGoToScreenTimeout ) && ( false == application ().isScreenTransitionInProgress () ) )
 {
 application ().gotoOtherScreen ();
 }
}

//---------------------------------------------------------
void ScreenOne
::handleKeyEvent ( uint8_t key ) // override final
{
 if ( false == application ().isScreenTransitionInProgress () )
 {
 application ().gotoOtherScreen ();
 }
}

 

 

 Thanks.

 

Best answer by GaetanGodart

Hello @ferro ,

 

I do not think you need to do that.

Simply call it in your even handler and, as far as I know, as soon as the transition starts, you are basically not in that screen anymore.

Here is the code generated by TouchGFX Generate when you add a transition from screen1 to screen2 in an interaction :

void Screen1ViewBase::buttonCallbackHandler(const touchgfx::AbstractButton& src)
{
 if (&src== &button1)
 {
 //Interaction1
 //When button1 clicked change screen to Screen2
 //Go to Screen2 with screen transition towards East
 application().gotoScreen2ScreenSlideTransitionEast();
 }
}

Here, we do not check for current transition.

If you want to double check that, you can try to call it multiple time in a handleTickEvent.

 

Regards,

1 reply

GaetanGodart
GaetanGodartBest answer
Technical Moderator
September 27, 2024

Hello @ferro ,

 

I do not think you need to do that.

Simply call it in your even handler and, as far as I know, as soon as the transition starts, you are basically not in that screen anymore.

Here is the code generated by TouchGFX Generate when you add a transition from screen1 to screen2 in an interaction :

void Screen1ViewBase::buttonCallbackHandler(const touchgfx::AbstractButton& src)
{
 if (&src== &button1)
 {
 //Interaction1
 //When button1 clicked change screen to Screen2
 //Go to Screen2 with screen transition towards East
 application().gotoScreen2ScreenSlideTransitionEast();
 }
}

Here, we do not check for current transition.

If you want to double check that, you can try to call it multiple time in a handleTickEvent.

 

Regards,