Page 1 of 1

CreateApp example not working?

Posted: Thu Mar 25, 2021 3:30 pm
by amyren
I see the need to learn myself to use RapaGUI, and been looking at some of the included examples.

There is one example in the function reference, moai.CreateApp.
This seem to be like a fully working program, ready to run just by adding require at the top of the script.
What I like about it, from a beginners perspective, is that it has the xlm part in the script so there is no need to have an external xml file in this example.

When running it, it does open a small window with a button, as intended. But looking at the code, it is suposed to output a debugprint message when clicking the button.
But that part is not doing anything, so I wonder what is missing from the example?

Here is the script, unmodified from the docs, exept for adding require "rapagui" at the top.

Code: Select all

@REQUIRE "RapaGUI"
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

Re: CreateApp example not working?

Posted: Thu Mar 25, 2021 4:53 pm
by plouf
button has no id to trigger to

change the button line to

Code: Select all

         <button id="set_your_id_here">Hello World!</button>

Re: CreateApp example not working?

Posted: Thu Mar 25, 2021 6:44 pm
by amyren
Thanks, that was it. Now it does what it should.
I guess the RapaGUI documentation should be updated accordingly.