How to pop modal dialogs off until the root dialog is reached?

202 views
asked Jul 13, 2017 in GUI Development by xaviesh
Hello,

       I have a scenario where I have a bunch of modal dialogs launched from one to another. If it's easier to understand, they're setup dialogs that the user traverses through to launch a command in the device. Once the command is launched, a new dialog is shown to show the status of the command that was launched. Once this command is stopped by the user, ideally we would like to go back to the initial root screens from which the setup dialgos were launched. All dialogs are launched through BeginModal()'s and works great. I tried to do a EndModal() by specifying the z-order but that didn't work. What would be the recommended method to remove modal dialogs from the stack? Do I need to store the Core::Groups that I would like removed on a stack to be removed, maybe?

Thanks!

1 Answer

+1 vote
answered Jul 13, 2017 by Paul Banach
 
Best answer

Hi,

if you want to close all currently existing modal dialogs, do it in a loop. For example:

var Core::Root  root       = GetRoot();
var Core::Group modalGroup = root.GetModalGroup();

while ( modalGroup != null )
{
  // Remove the dialog from its owner.
  modalGroup.Owner.Remove( modalGroup );

  // ... and end the modal state for this group
  root.EndModal( modalGroup );

  // Get the next modal group from the modal stack
  modalGroup = root.GetModalGroup();
}

Similarly, you can close several nested dialogs until you reach one particular stop dialog. You need to know the stop dialog and then you can test in the loop whether the dialog has been reached:

[...]

var Core::Group groupToStop = ...

while (( modalGroup != null ) && ( modalGroup != groupToStop ))
{
  [...]
}

Does it help you further?

Best regards

Paul Banach

commented Jul 19, 2017 by xaviesh
Works perfectly, thank you!

Embedded Wizard Website | Privacy Policy | Imprint

...