let me first address the error message. Your implementation is correct. The problem, you use the method GetRoot() during the initialization of an object. At this time the object is not yet part of the view tree. As consequence the method GetRoot() returns null. What can you do?
Option 1: Defer the operation. For this purpose
- add a new slot method to the affected component
- Move your implementation from the Init() method the slot method.
- In the Init() method just request the slot method to be called (later). Use the postsignal statement for this purpose.
Option 2: May be you can avoid the usage of GetRoot()? If you want the dialog to be presented in context of the component itself, you can just call PresentDialog(...) without the preceding root.
Now let me address your particular application case.
1. The buttons (the drawer) I would implement as a separate GUI component which is shown directly within the application (root) component.
2. To present the dialogs so that they don't interfer with the drawer I would create an empty component and arrange in the application (root) object restacked just behind the drwer component. This component let be named e.g. Container.
3. When the user presses a button in the drawer, the resulting dialog is presented in context of the Container component. Youz have two options:
Option 1: The drawer creates and presents the diualogs by itself. In such case the drawer need to know the Container component. The simplest would be:
- to have a variable in the drawer component declared with the type Core::Group.
- In the Init() method of of the application component just initialoize the variable as follows:
Drawer.TheVariable = Container;
- Now you can access from the drawer the Container component and present the dialogs. For example:
TheVariable.PresentDialog( dialog3, ... );
Option 2: Delegate the operations to the application component. For this purpose:
- For every button in the drawer have a corresponding property in the drawer component declared with the type slot.
- Assignbing a value to one of the properties causes the assocuated onset method being executed.
- In the onset method just assign the value to the corresponding button.
- For every button in the drawer have a slot method in the application component.
- In Inspctor window configure the above mentioned properties of the drawer so that they refer the corresponding slot methods.
Now when the user presses a button, a slot method in the apploication component is executed.
- In the slot method implement the code to present the dialog in context of the Container component. For example:
Container.PresentDialog( dialog3, ... );
Now let me address your third question, how to hide a dialog while presenting another one. THis can be achieved very conveniently by using the method SwichToDialog().
I hope it helps you furter.