cancel
Showing results for 
Search instead for 
Did you mean: 

How to trigger modal screen from model

JPabl.1
Senior

Hi there Touchgfx team!

I need to trigger a modal in 15 different screens, like this: 

JPabl1_1-1730468866905.png

 

I had a similar question on another post, and the solution works if I use buttons, but not if I send the notification from the model, which is what I need.

The post is: https://community.st.com/t5/stm32-mcus-touchgfx-and-gui/how-to-trigger-modal-in-all-screens-from-the-model/td-p/735616 

If I use a button like this the resulting screen is the one above. 

JPabl1_0-1730468814910.png

If I create an interaction on the screen, that when called changes the screen to the modal, this is what happens:

JPabl1_2-1730469008257.png

 

What I need is to call the interaction from the model, not to use a button. But the result is different than expected. 

Thanks a lot in advance!

1 ACCEPTED SOLUTION

Accepted Solutions

You can create a container for your popup/modal.
If you set its background to semi transparent greyscale it will darken its background (which is your current screen).

You add the this container as the top element, but set it to invisible in TouchGFX. If you need to show it you can set it to visible in your application.

Kudo posts if you have the same problem and kudo replies if the solution works.
Click "Accept as Solution" if a reply solved your problem. If no solution was posted please answer with your own.

View solution in original post

3 REPLIES 3

You can create a container for your popup/modal.
If you set its background to semi transparent greyscale it will darken its background (which is your current screen).

You add the this container as the top element, but set it to invisible in TouchGFX. If you need to show it you can set it to visible in your application.

Kudo posts if you have the same problem and kudo replies if the solution works.
Click "Accept as Solution" if a reply solved your problem. If no solution was posted please answer with your own.
JPabl.1
Senior

I have 15 different screens with 3 different modals, so I'm looking for a more streamlined way to do it.

The other post suggested creating a separate screen for each modal. That works really good because I only need to create the notify function for each screen. But the problem is that it only works with the buttons, and not when sending a notify from the model. 

 


@JPabl.1 wrote:

But the problem is that it only works with the buttons, and not when sending a notify from the model. 


It should work. You can add the notify as a virtual method in modellistener and implement it in the presenters and view of each screen. In the presenter it should just be a call to the view method.

Something like:

//model.cpp:
m_modelListener->notify()

//modellistener.h:
virtual void notify() {}

//ScreenNamePresenter.hpp:
virtual void notify();

//ScreenNamePresenter.cpp:
void ScreenNamePresenter::notify()
{
  view->notify();
}

//ScreenNameView.hpp:
void notify();

//view cpp:
void ScreenNameView::notify()
{
  popup.setVisible(true);
  popup.invalidate();
}

Let me know if it works.

Kudo posts if you have the same problem and kudo replies if the solution works.
Click "Accept as Solution" if a reply solved your problem. If no solution was posted please answer with your own.