cancel
Showing results for 
Search instead for 
Did you mean: 

Call goto screen transition function from presenter>activate()

Dfarr.1
Senior

I'm trying to redirect away from a screen during activate() based on some model state information before anything is shown on screen. But I've only managed to get it working on some screens and not others even though I'm following the same pattern everywhere (call function defined in modelListener>call model defined function> call FrontEndApplication::gotoScreenNoTransition() ).

I feel like I'm missing something here. Is there an intended way to do this?

21 REPLIES 21
Dfarr.1
Senior
void MasterEditConfigView::setupScreen()
{
    if (!presenter->Authenticate())
    {
        //not logged in yet.  Change screens
        GoTo_MasterEditLogin();
    }
 
...
}

the presenter function simply retrieves a bool value from the model.

To clarify, my action is GoTo_MasterEditLogin(). Its linked to an interaction that causes the screen transition I want. I've used this elsewhere in my application without issue, its definitely working properly. Except I don't see a screen transition when calling it from inside view.SetupScreen().

Alexandre RENOUX
Principal

Hello Dfarr.1,

Yes indeed maybe in setupScreen it's not possible but I need to investigate to confirm that. So in the meantime let's forget about this method. There's another one but I need more info on your UI concept.

I believe you don't need to prevent a screen from being displayed. So please could you provide more information ?

/Alexandre

MM..1
Chief II

When you debug your call where is returned with ignore screen change?

And i create app without touchevents and dont use presenter completely...I use C memory struct variable to share between hw (other tasks), model, view.

Dfarr.1
Senior

Alright, I've tried another designer pathway for this problem. I've created an interaction which is triggered by "Screen is Entered". According to the documentation, this trigger actually fires when the screen transition is complete.

This works. It executes the screen transition I want. BUT, there's a visible flash of the view from which its called. I would much prefer not to draw the new screen at all until after this authentication has occurred.

Is it possible to suspend draw until after the "Screen is Entered" interaction is triggered?

view.setupScreen() -> viewBase.action() -> application().gotoScreenNoTransition() -> FrontendApplicationBase::gotoScreenNoTransition

void FrontendApplicationBase::gotoMasterEditConfigScreenNoTransition()
{
    transitionCallback = touchgfx::Callback<FrontendApplicationBase>(this, &FrontendApplication::gotoMasterEditConfigScreenNoTransitionImpl);
    pendingScreenTransitionCallback = &transitionCallback;
}

Once the execution reaches this point, I don't see a change to the pendingScreenTransitionCallback variable if the screen transition is called from inside setupScreen(). transitionCallback does correctly contain the TransitionImpl. But 0x0 is stored to pendingScreenTransitionCallback,

If I call my action from anywhere else, pendingScreenTransitionCallback is set as expected to the function pointer of the TransitionImpl. But not when its called from inside view.setupScreen() or presenter.activate(). Code execution reaches that line (4), but the value isn't set. Its very strange. I feel like I'm overlooking something.

Later on MVPApplication rejects this screen transition pointer (0x0) as invalid, so no transition occurs.

    void evaluatePendingScreenTransition()
    {
        if (pendingScreenTransitionCallback && pendingScreenTransitionCallback->isValid())
        {
            pendingScreenTransitionCallback->execute();
            pendingScreenTransitionCallback = 0;
        }
    }

I'm implementing a basic login screen with persistence. If the user has logged in already this session, the login screen is bypassed and the screen is redirected to the password-protected screen without requiring re-login.

Similarly, the password-protected screen checks if the session is authenticated any time it loads. If not, it redirects away to the login screen to re-enter the password.

I was hoping to accomplish these redirects before drawing anything to the screen.

I've chosen to do it this way because there are multiple entry points into both the login screen and the password-protected screen. I could put the authentication check at each of those entry points instead, but its more code to maintain. If I can simply have the screen do the check before it draws, it would be centralized, easier to maintain. The authentication occurs where its actually needed, rather than on a handful of other screens that don't actually care about authentication.

I made a mistake. pendingScreenTransitionCallback is being set to the function pointer correctly.

But by the time evaluatePendingScreenTransition is reached, it has been set to 0x0.

I think what's happening is I'm calling a screen transition in the middle of another screen transition. And there's some cleanup code at the end of the screen transition execution that resets that function pointer when it ends. So the function pointer change I make during transition is wiped out before it gets a chance to be executed.

I mean use special screen for login and switch screens for this isnt best idea. Why you don use Modal window widget? ModalWindow | TouchGFX Documentation

I understand. I will consider the use of a modal window.