Quick Tip: Opening, Shown, Closing and Closed – Xojo Programming Blog

Javier’s post raises several questions.

  1. He mentions the Order buttons in the Command Bar. Is that the Tab Order?
  2. Is Xojo finally documenting the order of the Opening events? And is that in Tab Order? Was that an intentional statement or a mistake. Xojo has always said that you can’t count on the order of the control Opening events, as they reserved the right to change it if needed.
  3. He says “the app will start to raise the Shown event on every one of the webpage controls”. Does a WebControl have a Shown event? I don’t see it in the documentation.

It would be on WebUIControl.

Over the years, I can attest that (using API1) for a Window,
Open sometimes never fires at all, and can sometimes fire after Activate.
Does this mean it is certain that the order is fixed under API2?

Hi @Jeff_Tullin

I’m interested to know under what scenarios happened this? (Open event not firing on a Window).

Hi @Tim_Hare

  • 1 .You can change that using these buttons in the command bar:

Screenshot 2023-02-10 at 08.12.33

  1. Nobody can warranty what changes can be made in the underlying OSs in the future… but this is how it has been going for long, long time.
  2. You can find the documentation about the Shown event, related to WebUIControl here.
1 Like

I’m interested to know under what scenarios happened this?

Me too. mentioned it on the forum a few times years ago, could never repeat outside of a full project, and once I had a workaround I stopped worrying about it.

How does changing the Z-Order of a group of controls change the order of the Opening events for the entire window? I must be missing something.

As you can see here, you can use it to change the order of the Opening event in the controls added to the Window: https://drive.google.com/file/d/1csD1EA9IivSJOt4oXPMLQjJsfVjJz29D/view?usp=share_link

@Javier_Menendez it would be useful if Xojo can provide a Z-Order dialog where we can reorder just like the Tab Order dialog. Is there a feature request for this?

Manually placing the controls in the order that we want Opening to fire, or clicking these buttons to change the order to what we want:
Screenshot 2023-02-10 at 08.12.33
is hard because we don’t have a reference for all the controls that are not top or bottom.

Top, opening fires last (for controls):
image

Bottom, opening fires first:
image

How do I know if a control fires second, third or 45th if all show this:
image

Hi @AlbertoD

I don’t remember if there is an old or not-that-old request for that. But it makes sense, yep. :thinking:

Using the MenuItem / Window, I would be very happy to be able to select many entries at once to place them (Labels for example) at the bottom leaving the TextFields/TextArea/ListBox at the top: easier to set the Tab order that way !

We shouldn’t be needing z-order to set the order of Opening events in constrols. I use it to (for example) make sure that when scrolling a canvas, controls that stay off th canvas and vanish, stay hidden.

Setting the firing order of Openeing events, if this is possible, ought to be a separate feature.

Xojo shouldn’t be advertising this as a way to control event order IMHO. Just because it does behave that way right now, doesn’t mean they’ll be able to keep it working that way in the future.

This falls under the category of a “variable implementation detail” and should never be documented, not even in a blog post. Setting this as a documented behavioral expectation is only going to ■■■■ people off when it has to change later.

PLEASE NOTE: Because of the distances involved in a web app between browser and server, setting the order of the controls isn’t going to guarantee the order of events anyway. Not all events take the same exact route back to the server and it’s entirely possible that they could arrive at the server in some other order. That won’t be true locally of course because of the short distances involved.

The moral of the story is: Don’t rely on similar events happening in any particular order. Sure, you can expect that Opening happens before Shown on one particular control, but you can’t even be sure that Opening on one will precede Shown on another, especially if you are adding controls dynamically.

5 Likes