Page 1 of 1
running RapaGUI docs examples
Posted: Fri May 31, 2019 12:18 pm
by amyren
Looking in the docs for moai.CreateApp, moai.CreateDialog and moai.CreateObject there are some examples included in the docs.
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
moai.CreateApp will run as a standalone program, just by adding the
@REQUIRE "RapaGUI" at the start of the code.
But for some reason the eventhandler does not seem to be triggered, so the DebugPrint is not happening. What is missing in the example?
For the moai.CreateDialog and moai.CreateObject examples, they will both return errors and will not run at all.
Do these examples need to be added to some other existing program to work, or are there something wrong/missing from those eamples?
Re: running RapaGUI docs examples
Posted: Fri May 31, 2019 2:38 pm
by airsoftsoftwair
DebugPrint() won't work by default in executables compiled by Hollywood. You have to explicitly enable debugging support in executables by doing the following:
Alternatively, use
ConsolePrint().
Re: running RapaGUI docs examples
Posted: Sat Jun 01, 2019 12:44 pm
by amyren
airsoftsoftwair wrote: ↑Fri May 31, 2019 2:38 pm
DebugPrint() won't work by default in executables compiled by Hollywood. You have to explicitly enable debugging support in executables by doing the following:
Alternatively, use
ConsolePrint().
That is true, but there is another thing missing from making the example work.
I did also try to replace the Debug part with a simple End
Code: Select all
InstallEventHandler({RapaGUI = Function(msg)
If msg.attribute = "Pressed" Then End
EndFunction})
And even tried
Code: Select all
InstallEventHandler({RapaGUI = Function(msg)
End
EndFunction})
It seem to me there is something missing with that eventhandler, preventing it from being processed
Re: running RapaGUI docs examples
Posted: Sat Jun 01, 2019 1:16 pm
by airsoftsoftwair
Alright, now I see it
Your button doesn't have an id which is why it cannot generate any events. Just use
Code: Select all
<button id="btn1">Hello World</button>
and it will work...
Re: running RapaGUI docs examples
Posted: Sat Jun 01, 2019 1:40 pm
by amyren
Thanks, that was it
Will you perhaps update that example in the docs?
What about moai.CreateDialog
Code: Select all
@REQUIRE "RapaGUI"
moai.CreateDialog([[
<dialog id="dlg" title="Question">
<vgroup>
<text>What is your name?</text>
<textentry/>
<hgroup>
<button>OK</button>
<button>Cancel</button>
</hgroup>
</vgroup>
</window>
]])
mui.DoMethod("dlg", "showmodal")
Running this results in this message:
Error in line 2 (Unnamed3): Error parsing XML: mismatched tag (line: 10)
and moai.CreateObject
Code: Select all
@REQUIRE "RapaGUI"
moai.CreateObject([[
<window id="newwindow" title="A new window">
<vgroup>
<button>Hello World!</button>
</vgroup>
</window>
]])
mui.DoMethod("app", "addwindow", "newwindow")
mui.Set("newwindow", "open", True)
This gives te following message:
Error in line 24 (Unnamed2): Table mui{} not found!
Which I guess is due to a misspelling in the example,
mui.DoMethod and mui.Set should be spelled
moai.DoMethod and moai.Set
When correcting this, the following message is shown when running:
Error in line 24 (Unnamed2): Cannot find MOAI object "app"!
Re: running RapaGUI docs examples
Posted: Sun Jun 02, 2019 5:53 pm
by airsoftsoftwair
amyren wrote: ↑Sat Jun 01, 2019 1:40 pm
Thanks, that was it
Will you perhaps update that example in the docs?
Right, that's confusing for newbies. I've added IDs to all buttons now in the docs.
What about moai.CreateDialog
Code: Select all
@REQUIRE "RapaGUI"
moai.CreateDialog([[
<dialog id="dlg" title="Question">
<vgroup>
<text>What is your name?</text>
<textentry/>
<hgroup>
<button>OK</button>
<button>Cancel</button>
</hgroup>
</vgroup>
</window>
]])
If you use <dialog> then you obviously need to close that with </dialog>, not </window>.
This gives te following message:
Error in line 24 (Unnamed2): Table mui{} not found!
You're mixing MUI Royale and RapaGUI. MUI Royale uses the "mui" table, RapaGUI uses the "moai" table. Pun intended.