It looks like you're new here. If you want to get involved, click one of these buttons!
if JS then JS.eval([[ window.saveWarning=false; window.saveWarningListener = (e) => {if (window.saveWarning==true) {e.preventDefault(); e.returnValue='';}}; window.addEventListener('beforeunload',saveWarningListener); ]]) end function saveWarning(f) if JS then if f then JS.eval("window.saveWarning=true;") else JS.eval("window.saveWarning=false;") end end end |
Comments
I want to keep track of the visibilitychange event that fires when switching tabs.
This code works:
PS: don't worry too much about this option. If you can't make it work you will get frustrated and start hating gideros but it's not gideros fault I am not sure you could do this in other engines too
PS2: you can also let the user pause himself the game with a key (for example the P key)?
Likes: E1e5en
@MoKaLux thanks for the link to the post. I searched the forum but missed it.
The documentation does not indicate that the JS.eval() function can return values. So I figured out how to return a value from JavaScript to Lua. This example helped me figure it out, thanks.
As a result, you can do this:
P.S. @MoKaLux you have a very categorical thought. If I can't get what works for others, it means that the problem is with me, not with the engine.
This option is available in other engines, and will appear in the Gideros engine in future releases. About it wrote @hgy29 in community chat, we did discuss this issue. Most likely it will be available through the Event.APPLICATION_SUSPEND event, Event.APPLICATION_RESUME.
Update:
It's funny, but yesterday the documentation for the JS.eval() function was different, now there is more information. @MoKaLux thanks!
Likes: MoKaLux, SinisterSoft
Likes: MoKaLux, E1e5en
https://deluxepixel.com
And if you control the playback of music, etc., then of course you can immediately return to its original state.
Update:
It all depends on the task. I think further each developer will draw conclusions for himself and modify it as necessary.