Name
moai.CreateApp -- create application object from an XML source
Synopsis
moai.CreateApp(xml$)
Function
This function creates an application from the XML description passed in the xml$ argument. Please note that xml$ must be a string that contains the XML GUI declaration and not a filename. If you want to use an XML GUI declaration from an external file, you have to convert that file into a string first, e.g. using the FileToString() Hollywood function.

Once this function returns, you can talk to all your MOAI objects that you have defined in the XML GUI declaration using the moai.Set(), moai.Get() and moai.DoMethod() functions.

Please note that there can be only one application object per task so this function can only be called once. If you want to call moai.CreateApp() a second time, you have to free the old GUI first using the moai.FreeApp() call.

If you need to dynamically add objects like windows or buttons to your application object, you can use the moai.CreateObject() function to do this. For dialogs you can use the moai.CreateDialog() function.

Inputs
xml$
a string containing an XML GUI description
Example
moai.CreateApp([[
<?xml version="1.0" encoding="iso-8859-1"?>
<application>
   <window title="Test program">
      <vgroup>
         <button>Hello World!</button>
      </vgroup>
   </window>
</application>
]])

InstallEventHandler({RapaGUI = Function(msg)
      If msg.attribute = "Pressed" Then DebugPrint("Button pressed!")
   EndFunction})

Repeat
   WaitEvent
Forever
The code above creates a minimal GUI, just with a window and a single button.

Show TOC