cancel
Showing results for 
Search instead for 
Did you mean: 

how to trigger modal in all screens from the model

JPabl.1
Senior

Hi there Touchgfx team!

 

I have about 15 different screens. I also have a modal that says "battery critical level". I know how to propagate a notification from the model to the view to trigger this modal. 

My question is: is there an easy way to do this for 15 different screens? or everytime I need to override the notification function in each screen? 

Thanks a lot in advance

1 ACCEPTED SOLUTION

Accepted Solutions

@JPabl.1  Ah, sorry...forgot assets are also a must. try this one.

View solution in original post

9 REPLIES 9
ferro
Senior III

Hi @JPabl.1 , one solution could be a new screen, just with that warning message window and transparent background and transition to that. Then back to original screen.

Hi @ferro , thanks for the reply. 

 

I think that might work if the modal were just a single screen, but the UI requirements is for it to pop up on top of the current screen, like this: 

JPabl1_0-1729876995759.png

From your answer it seems the only way will be to the same on all screens?

 

Hi @JPabl.1 

 

but the UI requirements is for it to pop up on top of the current screen

 

Yes, and that is exactly what will happen. But I forgot one important detail.

Before transitioning to the warning screen, You must set the size of the default background box, named __background, injected automatically by Gfx Designer ( I suppose you use screen Base clasess) to the size of your modal widget. In that case, the previous screen content stays as it is ( in frame buffers).

 

From your answer it seems the only way will be to the same on all screens?

 

If you could rephrase that please, do not inderstand what you mean.

 

I've just remembered this post

https://community.st.com/t5/stm32-mcus-touchgfx-and-gui/persistent-widgets-between-screens/m-p/690918

 

So you mean just doing 

__background.setWidth(150);
__background.setHeight(150);
__background.invalidate();

 

And then call the function to jump to the warning screen?

Hi @JPabl.1 , yes, do this in the warning modal message screen, the one you want to transitioned to. In constructor or ::setupScreen ().

But now, I am not sure this works for modal widget. I use this technique with a plain container on a screen - to mimic a modal widget. But modal widget blures the background, i guess ?

What about creating a class with all possible (modal) messages  and let all screens inherit from that. Minimal writing and, most importantly, easy maintenance.

Seems to work in the attached simulation.

JPabl.1
Senior

How can I run that project? I get :

JPabl1_0-1730305127219.png

 

@JPabl.1  Ah, sorry...forgot assets are also a must. try this one.

That will do the trick, thanks a lot!