How to use addEventListener for browser window resizing in web deployment?

Andreas Bergendal andreas.bergendal at gmail.com
Sat Aug 6 07:44:31 EDT 2022


Hi all,

So I’ve been experimenting with web deployment with LC 10 dp 4. Now I would like my stack to be able to react to resizeStack events when the browser window is resized by the user. Or to adapt to e.g. a mobile browser screen size.

For this, if I understand correctly, some javascript needs to be used. I’ve tried to piece together how to do that from these sources:
https://livecode.com/using-the-new-web-features-in-livecode-10-dp-1/

and Ali Lloyd’s cool WordLC app:
https://alilloyd.livecodehosting.com/wordlc/wordlc.html

where he uses window.addEventListener(”resize” […] etc in the html file to catch browser window resizing for the stack to react on. However, as I can’t see his LC script side of it, I fail to figure out the proper adaptation to my needs:

I want my stack to get, from javascript, the impulse that the browser window has changed its width/height and what the new width/height is, in order to trigger a normal resizeStack handler to deal with that.

Ideally, the javascript part of this should be included by LC in the standalone build, and I hope that’s what they plan at least when LC10 stable ships (seems logical), but in the meantime - can someone please help get the code right?

/Andreas


More information about the use-livecode mailing list