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

1 Answer

0 votes

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";
  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";  
    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

Thanks Paul, That was very helpful.


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