How do I determine (or set) the order that controls are opened?

Is there some rhyme or reason to the order that controls are opened when a window opens? Better yet, is there a way to set that order (at least for a finite set of controls)? My window has controls that size and position themselves when opened, and that size/position depends on the size/position of many of the other controls on the window. You can see where this is going…

I’m sure that this is documented somewhere, but this type of information is impossible to find in a !@#$ Wiki.

pretty much… NO

If the order you initialize controls matters, don’t do it in the control open events!!

Do it in the Window open event. The Window open event is guarantied to be called AFTER all the control open events and there you can control the order you setup the controls

[quote=155975:@William Koperwhats]Is there some rhyme or reason to the order that controls are opened when a window opens? Better yet, is there a way to set that order (at least for a finite set of controls)? My window has controls that size and position themselves when opened, and that size/position depends on the size/position of many of the other controls on the window. You can see where this is going…

I’m sure that this is documented somewhere, but this type of information is impossible to find in a !@#$ Wiki.[/quote]
I’m using controlsets and instantiate controls at startup. The properties of each control are stored in a database including an index number for the order of creation.

After creating the controls I run a method to place any elements which need to be situated relative to others and then I make everything visible.

But I only do all of this, because the User Interface can be drawn or altered by the user himself.

In your case I would use a method from the window open event in order to relatively place controls.

[quote=155975:@William Koperwhats]Is there some rhyme or reason to the order that controls are opened when a window opens?
[/quote]
Yes - more or less the creation order but thats not documented so it could change.

No

[quote=155975:@William Koperwhats]My window has controls that size and position themselves when opened, and that size/position depends on the size/position of many of the other controls on the window. You can see where this is going…
[/quote]
Yeah don’t do that there because the control you rely on may not even exist yet.
Do this in the Window.Open event as all the controls will exist then

Probably not in the wiki as this isn’t a “language” thing - thats what IS is the wiki - “This command you use like this”
This may be mentioned in the various users guides

If you need to do something that depends on several controls then you should do it at a point that all the controls exist - the open event of the window.

Never access another control in the open event of a control. Use the Window open event as the others have said.

Argh! I will be doing a lot of cut and pasting of code tomorrow morning. Thanks everyone for pointing this out.

[quote=155980:@Karen Atkocius]If the order you initialize controls matters, don’t do it in the control open events!!

Do it in the Window open event. The Window open event is guarantied to be called AFTER all the control open events and there you can control the order you setup the controls[/quote]
This is how I have to do it also, I ran into problems with kind of thing when they were in each controls open event.

[quote=155975:@William Koperwhats]Is there some rhyme or reason to the order that controls are opened when a window opens? Better yet, is there a way to set that order (at least for a finite set of controls)? My window has controls that size and position themselves when opened, and that size/position depends on the size/position of many of the other controls on the window. You can see where this is going…

I’m sure that this is documented somewhere, but this type of information is impossible to find in a !@#$ Wiki.[/quote]
The top-down sequence of control in the “.xojo_window” file seem to determine the order in which the controls in a window are opened ( = “the ‘Open’ event is called”) by Xojo at runtime. If that sequence is changed in the file “.xojo_window” manually and the project is opened again in Xojo then the sequence of control opening is also changed accordingly in Xojo v2014r2.1 on Windows 7.

This could change
Dont rely on it

[quote=155975:@William Koperwhats]Is there some rhyme or reason to the order that controls are opened when a window opens? Better yet, is there a way to set that order (at least for a finite set of controls)? My window has controls that size and position themselves when opened, and that size/position depends on the size/position of many of the other controls on the window. You can see where this is going…

I’m sure that this is documented somewhere, but this type of information is impossible to find in a !@#$ Wiki.[/quote]

The solution is probably not to try and have a precise opening order with bits of code in each control’s Open event. I just completed a web app geared towards iOS users where I have controls relative to each other and manage their place according to devices and their rotation.

In Web apps, we have a shown event that takes place after everything is set, controls drawn, and stuff done. That is where I do it initially (then in resized for rotation). In a desktop app, activate is probably the best equivalent. It takes place at the very end, after the window open. Why don’t you manage all your controls relative placement and sizing once and for all there ? Use a boolean flag so it happens only once, and you are sure every control is where it should be. You can even hide the window while you prepare the stage for the opening of the curtain, then voilà, present the completed window…

Seems a whole lot easier to do…