486 views
in GUI Development by
Is there a method called when I dialog is closed?

1 Answer

0 votes
by

Hello Mike,

the method UpdateViewState() could be suitable for this purpose. Each component manages few common states (Enabled, Focused, etc.). When the component state changes, the component method UpdateViewState() is invoked automatically. In case of a component presented as dialog, the state Dialog is activated. When the dialog is dismissed later, the state Dialog is deactivated again. For this purpose:

Step 1: In the class implementing the dialog component, override the method UpdateViewState. (Possibly the method is already overridden, then skip over this step).

Step 2: Edit the UpdateViewState() method and implement following code:

// Is the state 'Dialog' actually active?
if ( aState.contains( Core::ViewState[ Dialog ]))
  trace "I'm dialog";
else
  trace "I'm not a dialog";

Please note, the method UpdateViewState() is also invoked when any other state alternation took place. Therefore you will get multiple 'I'm dialog' or 'I'm not dialog' log entries. You will need to add a variable to track the latest Dialog state:

Step 3: Add an new variable to your component. Name it e.g. lastDialogState.

Step 4: Adapt the data type of the variable to be bool.

Step 5: In the UpdateViewState() method use now the variable to track the Dialog state:

// Does the dialog state change?
if ( aState.contains( Core::ViewState[ Dialog ]) != lastDialogState )
{
  if ( aState.contains( Core::ViewState[ Dialog ]))
    trace "Now I'm dialog";  
  else
    trace "Now I'm not a dialog";

  // Remember the 'dialog' state
  lastDialogState = aState.contains( Core::ViewState[ Dialog ]);
}

Does it help you further?

Best regards

Paul Banach

by
Thanks Paul, That was very helpful.

Mike

Ask Embedded Wizard - Archive

Welcome to the Ask Embedded Wizard archive. This community forum served us well for many years, but we've evolved our support approach!

Your resources:

The Embedded Wizard Online Documentation provides comprehensive documentation, tutorials, examples and ready-to-use software packages.

For dedicated assistance, explore our Embedded Wizard Product Support.

You can still browse the valuable discussions from our community history here.

Embedded Wizard Website | Privacy Policy | Imprint

...