547 views
in GUI Development by

Bit of a newbie question. How does one make changes in a Dialog from another just presented by it?

My ::MainDialog does a PresentDialog(SubDialog,...) and then in a SubDialog method I do the following to no avail.

var Core::View view = Owner.FindPrevView( this, Core::ViewState[] );
var Application::MainDialog dialog = (Application::MainDialog)view;
dialog.DialogTitle.String = "test";

I read https://doc.embedded-wizard.de/compositing-component-appearance#15 but something must not be sinking into my head :)

 

1 Answer

0 votes
by

Hello,

if you present SubDialog in context of MainDialog, (the method PresentDialog() is invoked in scope of MainDialog) then the SubDialog can access MainDialog via its own Owner variable. For example:

// Being in a sub dialog assume the owner is the searched dialog
var Application::MainDialog mainDialog = (Application::MainDialog)Owner;

// Found?
if ( mainDialog != null )
{
  ...
}

If there is no direct relationship between the both dialogs, you can e.g. use a variable in SubDialog to refer to the MainDialog. Just in the momenent when you create or present the SubDialog, initialize the variable with a a reference to MainDialog:

// Create a new instance of the sub dialog.
var Application::SubDialog subDialog  = new Application::SubDialog;

// The known instance of the previously opened main dialog.
var Application::MainDialog mainDialog = ...;

// Let the sub dialog store a reference to the main dialog. In this
// manner the sub dialog can access the main dialog
subDialog.YourVariable = mainDialog;

// Present the sub dialog in context of e.g.the application's root object:
GetRoot().PresentDialog( subDialog, ... );

Then when SubDialog wants to access functionality from MainDialog, do this via the variable. Please see also Implementing component interface.

If there is no direct relationship between the both dialogs, you can use the method FindDialogByClass() and search the entire tree of dialogs for the particular one. See also the section Enumerate and search for existing Dialogs. For example:

// Being in a sub dialog search for the main dialog (if any)
var Application::MainDialog mainDialog =
  (Application::MainDialog)GetRoot().FindDialogByClass( Application::MainDialog );

// Found?
if ( mainDialog != null )
{
  ...
}

Best regards

Paul Banach

by

I just noticed if i do the following in a subDialog's Init{} the mainDialog var comes back null. Why is that? Because the Viewtree hasnt been updated? Moreover, where should I do my subDialog updates based on mainDialog.properties if not in Init{} ?

I tried moving this to a Slot{} and doing a "postsignal Slot" from Init{}. But it still turns up null... ??

 

/ Being in a sub dialog assume the owner is the searched dialog
var Application::MainDialog mainDialog = (Application::MainDialog)Owner;

// Found?
if ( mainDialog != null )
{
  ...
}
by

Hello,

when your subDialog is going to be created the corresponding Init() constructor is called. After the subDialog has been created, it is added to the component which contains the subDialog. For that reason, the Owner is null during the initalization.

Depending on what you want to do, you can override the methods UpdateLayout() or UpdateViewState() within your subDialog in order to implement your arrangement or configuration of your GUI component.

Best regards,

Manfred.

by
For now I was just trying to pull a Property from mainDialog and put it into a subDialog.textField.

I was able to get that done by differing the needed code into an initSlot{} and then using an idlesignal initSlot; in init{}

It' just a bit unclear to me why it needed an idlesignal and postsignal didnt work. I thought postsignal ran after subDialog is added to the component...no?
by

You are using PresentDialog - which is able to present a dialog with a certain transition. The internal handling and the completion of PresentDialog is also done with postsignal.

In case you are using no transitions, the dialog will immediately appear and your idlesignal will be delivered directly after the first update has happened. This why it works.

If you want to get a notification as soon as the PresentDialog has completeted, you can register a slot method as one of the parameters in the call to PresentDialog().

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

...