Name
moai.CreateDialog -- create dialog object from an XML source
Synopsis
moai.CreateDialog(xml$[, parent$])
Function
This function can be used to dynamically create a dialog object from an XML source. The newly created dialog object will also be automatically attached to your application so that it is ready for instant use. You should also specify a parent window for your dialog using the optional argument.

moai.CreateDialog() is very important because you should create dialogs only when you need them and destroy them as soon as you are finished with them. It is not advised to create all your dialogs on startup using moai.CreateApp() and keep them in memory all the time. Instead, you should use this function to create a dialog when you need it and then have it destroyed as soon as you are finished with it. The reason for this is that windows are quite a finite resource on some operating systems supported by RapaGUI. For example, on Windows there is a limit of about 10,000 windows per process. That might sound like sufficiently enough but keep in mind that on Windows every widget is a "window" for the operating system, e.g. every label, button, frame, checkbox, group, etc. in your application is a window so you should take care that you create your dialogs only as needed using moai.CreateDialog() and destroy them right afterwards.

In practice, it is advised to create a separate XML file for each of your dialogs and then use this function to convert the XML file into a dialog at runtime and have the dialog destroyed automatically by RapaGUI as soon as the user closes it.

Technically speaking, this function is just a convenience function which internally calls moai.CreateObject() and then adds the newly created object to the application object by calling Application.AddWindow. moai.CreateDialog() simply combines these two steps into one.

See Dialog class for more information on dialogs.

Inputs
xml$
a string containing an XML MOAI dialog description
parent$
optional: desired parent for the dialog object; see above for details
Example
moai.CreateDialog([[
<dialog id="dlg" title="Question">
  <vgroup>
      <text>What is your name?</text>
      <textentry/>
      <hgroup>
         <button id="ok">OK</button>
         <button id="cancel">Cancel</button>
      </hgroup>
   </vgroup>
</dialog>
]])

moai.DoMethod("dlg", "showmodal")
The code above creates a new dialog and shows it.

Show TOC