Javascript Pop-Up Window

Hi - I am creating a game in which players can share their results view the clipboard. I am doing this via javascript in the HTML template so I can get round the permissions limitations.

Everything works perfectly except for one slight … annoyance - the pop up window appears behind the game screen. Is there any way I can get the window to appear in front of the game?

This is of course for the HTML version of the game only.

Thanks.

Which pop-up window area you referring to?

The one I have created using css, html and JavaScript.

Well, Defold is rendered in a canvas element using WebGL. But that should not prevent a div from being overlayed. I suggest that you use your browser dev tools to check the CSS applied to the canvas and your popup and try to figure out the render order.

1 Like

I figured it out. I had the modal in the wrong container. Works like a charm now. Quite proud - found a way of pasting to the clipboard if HTML which the clipboard extension currently cannot do.

Nice! Can you share some more info about this? I wouldn’t mind adding something similar to the clipboard extension.

1 Like

Unfortunately, I don’t think you will be able to, as most of it is done outside of Defold.

The process was this.

(a) add HTML to the default template used by the Defold app. This was a simple modal div with two buttons.
(b) style the modal div with CSS.
(c) add Javascript. This was a listener for the ‘OK’ button of the modal and functions to call and close it.
(d) use ‘html5.run’ within Defold to call the modal and pass the string to the javascript function. When the user clicks on the ‘OK’ button the javascript function passes the string to the clipboard and closes the modal.

As I am sure you know access to the clipboard via HTML is limited, but one of the ways you can is in response to a Javascript click event.

Well, all of this can be made through the extension. But it might be better to leave the styling of the HTML popup to the developer (although the extension could provide a default).

Thanks for sharing!

2 Likes

Huh, forgot that there was already a discussion about HTML5 support here, and a proposed solution by @Pkeod :

1 Like