58.1 Overview

Window class creates top-level windows that can be filled with groups of widgets. These groups are children of the top-level windows. As such, groups are automatically relayouted whenever the size of their parent changes. This allows you to create flexible GUI layouts that automatically adapt to the available screen space. Additionally, you can also attach menubars and toolbars to a window.

Windows are children of Application class. When creating window objects dynamically, you first have to add them to the application object by calling Application.AddWindow.

If you need to open dialogs, you can do so by creating objects of Dialog class. Dialogs are special top-level windows which block the rest of the application until they are closed. Dialogs are typically used when user action is required to continue a task or to indicate that the application is currently busy. A dialog could show a progress bar then, for example. See Dialog class for details.

Here is a minimal example of creating a window in XML:

<window title="Hello World!">
       <button>Hello World!</button>

Note that the root element of a window always needs to be a single group object, i.e. an instance of Group class. See Group class for details. In our example, we use a <vgroup> as the root element. It is not allowed to have multiple elements at the window's root level. You must only use a single group object as the root element.

Windows that are declared in XML code that is parsed by moai.CreateApp() are opened automatically unless you explicitly request them to stay closed by setting Window.Open to False. Windows created by moai.CreateObject(), on the other hand, are not opened automatically. You first have to add them to the application's window list by calling Application.AddWindow and then set Window.Open to True.

Show TOC