How to create a splash window?

Discuss GUI programming with the RapaGUI plugin here
Post Reply
amyren
Posts: 352
Joined: Thu May 02, 2019 11:53 am

How to create a splash window?

Post by amyren »

I want to have a splash window to open at program start, and automaticly close it after a short time.
The example below will open the splash window and put it on top of the main program window. But the graphics are not drawn until it reaches the waitevent in the main loop, so obviously this is not the way to do it.

But where to put the command to close the window to make it work?
I tried removing the Wait() command, and using a timer instead and let it be called later from p_Eventfunc. But WaitEvent does not call the function until a GUI event is detected.

Another thing. Window.Borderless will only work for Android/Amiga? How to open a borderless window on windows?

Code: Select all

InstallEventHandler({RapaGUI = p_EventFunc})

moai.CreateObject([[
<window id="splash" Borderless="True" title="Splash Window">
<vgroup>
<image brush="2"/>	
</vgroup>
</window>
]])
moai.DoMethod("app", "addwindow", "splash")
moai.Set("splash", "open", True)
Wait(150)
moai.Set("splash", "open", False)

Repeat
	WaitEvent
Forever
User avatar
jPV
Posts: 603
Joined: Sat Mar 26, 2016 10:44 am
Location: RNO
Contact:

Re: How to create a splash window?

Post by jPV »

Maybe you could close it with the SetTimeout() and you can even use a temporary function inside it for closing:

Code: Select all

SetTimeout(Nil, Function() moai.Set("splash", "open", False) EndFunction, 3000) ; closes the window after 3 seconds
About the borderless window... another option is to use Hollywood's display for the splash window, instead of a RapaGUI window...
amyren
Posts: 352
Joined: Thu May 02, 2019 11:53 am

Re: How to create a splash window?

Post by amyren »

Thank you, that worked.
As mentioned above, I tried resolving it by using a timer. But since the timer itself did not create an event it did not work. So now I understand that the clue here is that SetTimeout() does create an event for WaitEvent() to detect.
I was not familar with the SetTimeout() command, so this could be useful for me also in other cases. This also led me to read some more in the docs and discovered other useful things as well as a bonus.

I did try setting it borderless because that the closegadget in the splash window did not only close the splash window, but also the main program. Instead I have now set CloseGadget="False".
Post Reply