moai.CreateDialog(xml$[, parent$])
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.
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.