18 views
in GUI Development by

Hi Gents,

 I have Application::MainMenu which contains just my menu system components.

I then PresentDialogs() into it when there's an onTap{} doing the following:

var Core::Group existingDialog  = mainDialog.FindCurrentDialog(); 
mainDialog.DismissDialog( existingDialog, null, null, null, null, null, false );

var Core::Group Whatever_Dialog = new Application::Whatever_Dialog;
mainDialog.PresentDialog(Whatever_Dialog, Transition, null, null, null, null, null, null, null, false );

 

This works fine unless Whatever_Dialog itself calls PresentDialog() to throw up some sub-Dialog. When that happens, and there's an onTap{}, the DismissDialog(existingDialog,..) errors out with: "The dialog component is actually not presented". As mainDialog.FindCurrentDialog() returns non-null with something, but its not actually presented on top any more. How can I deal with this? My onTap{} needs to dismiss whatever is presented even if that dialog called another PresentDialog().
 

1 Answer

0 votes
by

Hello Mike,

I suppose, the dialog returned by FindCurrentDialog() is not belonging directly to mainDialog. Possibly, it is a sub dialog of another dialog belonging to mainDialog. Try following code. It contains two modifications (1) it verifies whether the found dialog is belonging directly to mainDialog and (2) dismisses the dialog correctly in context of its Owner:

var Core::Group existingDialog  = mainDialog.FindCurrentDialog(); 

// (1)
if ( existingDialog.Owner != mainDialog )
  trace "This is some sub dialog";

// (2)
existingDialog.Owner.DismissDialog( existingDialog, null, null, null, null, null, false );

...

The above code should help to better analyse and explain the possible background of the problem. Now let me address how to solve it. I have understood, you want to replace the active dialog existing in mainDialog by a new Whatever_Dialog. Since the method FindCurrentDialog() searches all dialogs recursively, it may return one of the sub...sub dialogs. To find the active dialog existing directly within the mainDialog you use better the method GetDialogAtIndex() with 0 as parameter. Try following:

var Core::Group existingDialog  = mainDialog.GetDialogAtIndex(0); 

if ( existingDialog != null )
  mainDialog.DismissDialog( existingDialog, null, null, null, null, null, false );

...

I hope it helps you further.

Best regards

Paul Banach

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

...