998 views
in GUI Development by
After calling SwitchToDialog() he displayed view is not located at the same position as it has been, when only making the view visible/invisible.

What is the trick, to get the same postion?
by

To make the situation clearer:

When I crete this object and make it visisble/invisible everything works.

No there is a situation, where a timer must bring this object in the foreground again. RestackTop does not work for this. So I tried to do it using SwitchToDialog. This actually brings the object in the foreground, but the elements within the object are not positioned as they should be:

Applying an y-offset of strange 190 pixel positions the object, where it should be, but not all of its contents. The clock has to be positioned again by another y-offset. The touch handler of the clock on the other side does not need to be repositioned.

by

Why does RestackTop() not working? SwitchToDialog() uses internally also RestackTop(). When using RestackTop(), you should call the method in context of the Owner of the component you want to restack. For example, if you want to restack the GUI component named theComponent:

theComponent.Owner.RestackTop( theComponent );

Best regards

Paul Banach

1 Answer

0 votes
by

Hello,

The function SwitchToDialog()  (similarly to other functions to control the Dialogs) performs transitions when showing/hidding the Dialogs. The transitions include the positioning of the Dialogs. Per default the Dialogs are positioned in the center of the available screen area or the area of the superior component. What you can do:

If you want the Dialog to appear at predetermined position, you have to customize the transition used to show the Dialog. With this you specify the area within it the Dialogs are aligned and how the Dialogs are aligned. For example, if you intend to simply show/hide the Dialog without performing any animations, then:

1. Create a new Show/Hide Transition object.

2. Configure in the properties of the object how this transition should arrange the Dialogs.

With these properties you specify the layout constraints. To arrange the Dialog at the precise X,Y position, configure the property Alignment of the transition object with the value Effects::DialogAlignment[ AlignHorzLeft, AlignVertTop ]. and the properties MarginLeft and MarginTop with the desired X, Y values.

3. Finally, you pass this object in the aPresentTransition parameter (the second parameter) when calling the SwitchToDialog() method.

You can create the transition object in-place immediately before you call the SwitchToDialog() method:

var Effects::ShowHideTransition transition = new Effects::ShowHideTransition;

transition.Alignment  = Effects::DialogAlignment[ AlignHorzLeft, AlignVertTop ];
transition.MarginLeft = the_X_position;
transition.MarginTop  = the_Y_position;

SwitchToDialog( the_dialog, transition, null, null, null, null, null, null, null, null, false );

Or , if the Dialog position does not change, you can add the transition object to the GUI component where you plan to present the Dialog and configure its properties in Inspector.  The you simply pass the transition object in the parameter of the SwitchToDialog() method.

Hope it helps you further.

Best regards

Paul Banach

by

Hello Paul,

thank you for your advice. However, I still have som problems:

This is my dialog in the composer:

This is the same dialog on the real device:

An this is the correspendigng code:

var Hauptfenster::DialogUhrzeit dialog = new Hauptfenster::DialogUhrzeit;

// Connect a slot methods to signal when the user presses a button within the
dialog.onAccept = this.onAcceptUhrzeit;
dialog.onDecline  = this.onDeclineUhrzeit;

SwitchToDialog( dialog, dialogTransition, null, null, null, null, null, null, null, null, false );
dialog.Enabled = true;

// Obtain access to the root object.
var Core::Root rootObject = GetRoot();

// Add the alert component directly to the application component.
// Thereupon the alert panel will appear on the screen.
rootObject.Add( dialog, 0 );

// Make the alert panel modal now.
rootObject.BeginModal( dialog );

BTW: There is no difference if the dialog is modal or not.

by

Hello,

from your implementation I would expect an error. The problem here, you add/present the dialog twice: first with SwitchToDialog() then with Add().

The effect of SwitchToDialog() is always deferred by at least one postsignal. In other words, the resulting SwitchToDialog operation is pending while the dialog is added by invoking Add(). Shortly after this step the pending SwitchToDialog() operation is executed and the dialog is eventually moved to the position according to the layout constraints specified in the transition object used in the SwitchToDialog() invocation.

In any case, mixing the both approaches (Add() and SwitchToDialog()) is not reasonable. As far as I understand you want to show a modal panel only. In such case it is not necessary to use the dialog functionality. You can achive similar by using Add() to add the dialog and make the dialog modal by using BeginModal().

Best regards

Paul Banach

by
Hello,

sorry for wasting your time. Actually this was an implementation error. (Be careful with "$if $prototyper" !!!)
by
Hello,

don't worry. Does it mean, you were able to solve the problem?

Best regards

Paul Banach
by
Hello,

yes, problem is solved.

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

...