Skip to content

Quick Tip: Opening, Shown, Closing and Closed

Knowing the firing order of the Opening event in Xojo Desktop and Mobile apps, and the Shown event for Xojo Web apps, is important to using these correctly for a control’s initialization. The same can be said for Closing and Closed events. Read on for a breakdown of this order for Desktop, Web and Mobile apps developed in Xojo.

Opening in Desktop and Mobile Apps

  • First, the App Opening event will be fired first.
  • Next, the Opening event on every control of the default Window assigned to the App project. In this case, it will follow the same order in which the controls were added to the Window in the Layout Editor. It is possible to change that order using the Order buttons in the Command Bar in the Layout Editor.
  • Last, the Opening event will be fired on the default Window containing the controls.

Closing in Desktop Apps

When a Window is closed in a Desktop app, the Closing event will be fired following this order:

  • First, the Closing event will be raised on every control added to the Window, following the same order used when adding the controls to the Window in the Layout Editor. It is possible to change that order using the Order buttons in the Layout Editor toolbar.
  • Next, the Closing event will be raised in the Window itself.
  • Last, the Closing event will be raised in the App object of the Desktop app when the user quits the application.

Opening in Web Apps

This is the event firing order for Xojo Web apps:

  • First, the Opening event will be raised in the WebApp object.
  • Next, the Opening event in the WebSession object.
  • Next, the Opening event on every control added to the by default WebPage set in the WebApp object. In this case, it will follow the same order used when adding the controls to the web page in the Layout Editor. (It is possible to change that order using the Order buttons in the Layout Editor toolbar.)
  • Next, the Opening event will be raised on the default web page itself.
  • Next, the app will start to raise the Shown event on every one of the webpage controls following the same order used when they have been added to the page. (It is possible to change that order using the Order buttons in the Layout Editor toolbar.)
  • Last, the Shown event will be raised in the default webpage.

Closing in Web Apps

Regarding the Closing and Closed events, the Web App will follow this order:

  • First, the Closing event will be raised in the WebSession object.
  • Next, the Closed event will be raised on every one of the default webpages (or the pages shown), following the same order used when adding the controls to the page in the Layout Editor. (It is possible to change that order using the Order buttons in the Layout Editor toolbar.)
  • Last, the Closed event will be fired in the webpage itself.

Summary

As you can see, Xojo follows the firing same regardless of the target you choose for your project – Desktop, Web or Mobile apps. Obviously, Web apps do change a bit, because they deal with the WebSession object and also with the Shown event in addition to the Opening event. In Web projects, the Opening event happens on the server side, while the Shown event happens in the client (browser) side.

See related video at the Xojo Programming Language YouTube Channel.

Javier Menendez is an engineer at Xojo and has been using Xojo since 1998. He lives in Castellón, Spain and hosts regular Xojo hangouts en español. Ask Javier questions on Twitter at @XojoES or on the Xojo Forum.