427 views
in GUI Development by

Hi,

I wonder how I could use DismissDialog() to close all dialogs open in the application. Currently, I have implemented a menu with nested dialogs, where a new dialog is shown by means of PresentDialog() above the previous one. I would like to implement a slot that allows to close all these menu dialogs (the shown one and the hidden ones) at once when the proper KeyHandler.Filter is true. I guess I should use DismissDialog() individually for each dialog in the "menu tree", but I have not been able to find the proper way to do it.

I have had a look on the next example of "Managing dialogs (multiple screens)" documentation (https://doc.embedded-wizard.de/data/9.00/managing-dialogs-5.zip), but I cannot apply this way of working to my application -although I tried-, since I use several instances of different menu types of my creation (i.e. SCREENS::Menu and SCREENS::MenuPicker) along the menu tree, as you can see in the image below. In the start of the Application, I implement a new object of SCREENS::MenuSettings class to open the main menu and the rest of submenus are open from it according to selected item.

Any other idea?

Thanks in advance for your help and regards,

Fayna

1 Answer

+1 vote
by
 
Best answer

Hello Fayna,

I guess I should use DismissDialog() individually for each dialog in the "menu tree", but I have not been able to find the proper way to do it.

yes, this the right approach. The challenge here is to find all actually (or all desired) dialogs and dismiss them. You would implement for this purpose usually a loop. See the section Enumerate and search for existing Dialogs. It explains how to find dialogs existing actually within a group and it also demonstrates how to dismiss them. According to the description found there you could implement following code. It searches for all actually existing dialogs (therefore the search operation starts in the root object):

var Core::Root  theRoot = GetRoot();
var Core::Group dialog  = theRoot.FindCurrentDialog();

while ( dialog )
{
  dialog.Owner.DismissDialog( dialog, null, null, null, null, null, false );
  dialog = theRoot.FindCurrentDialog(); 
}

Important aspect: if your dialogs are using animations (transitions) to dismiss them, you can pass in the last parameter of the DismissDialog() method the value true for the second and all following dialogs. Then the dismiss animations are not performed one after another but simultaneously - all dialogs e.g. fade-out at the same time. If it is interesting you see the section Perform several Dialog transitions simultaneously.

Best regards

Paul Banach

by
Hi Paul,

Thank you for your feedback. Closing all dialogs at once works as expected now, and I have taken into account your comment related to simultaneous transitions.

Regards,

Fayna
by

Hi Paul,

I have created a GUI design with several components including Menu templates. When I move to screen named as base screen 1, it will present the Layout 1 dialog through startup screen. Within that dialog if I press menu icon it shows menu flows. when I press the done button in the MainMenu4, I need to dismiss all the menus and straightly come back to base screen 1. So that I have dismissed all the dialog but when simulating that one the simulation is halted. When I execute the above mentioned approach which you have suggested using FindCurrentDialog I comeback to root object. But It isn't the case I needed. How can I solve this issue.? Here I have attached the sample project for your reference.

Regards,

Sazna.

 

by

Hello Sazna,

the error is generated in following line:

This line tries to dismiss a dialog represented by an autoobject. This autoobject, however, was not used to present the dialog originally. In fact, the autoobject is not 'alive' at this moment, Therefore, just in the moment when this line is executed the system sees that the autoobject Application::MainMenu5 does not exist and creates a new instance of it. Then DismissDialog() is invoked with this instance as parameter. Since this new created instance was not presented as dialog, the execution stops with an error.

I hope this explanation helps you to solve the issue.

Best regards

Paul Banach

by
Hi Paul,

I understood the concept but I didn't find a way to get the desired operation. How those can be dismissed at once and return back to base screen 1?

Regards,

Sazna.
by

Hello Sazna,

as described in my initial answer, you implement a loop and by using the FindXXX methods you search for existing dialogs. These can then be dismissed. In most cases you use FindCurrentDialog(). The example from the initial answer dismisses all existing dialogs. If you want to dismiss only 3 latest presented dialogs, add a counter to condition in the loop. For example:

... or you test the class of the found dialog. The following code dismisses the dialogs as long as they descend from the generic Menu component:

I hope it helps you to find the right approach.

Best regards

Paul

by
Hi Paul,

Yes, it does! Thank you.

Regards,

Sazna.

Ask Embedded Wizard

Welcome to the question and answer site for Embedded Wizard users and UI developers.

Ask your question and receive answers from the Embedded Wizard support team or from other members of the community!

Embedded Wizard Website | Privacy Policy | Imprint

...