It was kind of tricky/slightly hacky but here is a demo with a console.log
when the dialog is closed:
https://jsoftware.github.io/j-playground/bin/html2/#url=https://gist.githubusercontent.com/joebo/6002c573f08b57c279c1203d7f5c4328/raw/f7035715b33ec37e09c01fe02e18e4b6bb45b9a9/jplayground%2520webgl
The relevant part is here:
//event to catch popup visibility change
const resizewatcher=new ResizeObserver(entries => {
for (const entry of entries){
const visible = !(entry.contentRect.width == 0)
console.log('popup visibility is: ' + visible);
}
})
var popupid = getid("popup")
//prevent adding the event multiple times if the script is run multiple
times
if (popupid.dataset.has_close_watcher == undefined) {
resizewatcher.observe(popupid)
popupid.dataset.has_close_watcher = true;
}
I thought about changing the popup code to emit an event when visibility
changed in start.js
https://github.com/jsoftware/j-playground/blob/9da3ae0509580f282cb09b93aa5817a2ac1d3152/bin/html2/start.js#L62
but instead just added a MutationObserver to watch the visibility change
idea from:
https://stackoverflow.com/a/70019354
On Sun, Jan 15, 2023 at 8:19 AM Raul Miller <rauldmil...@gmail.com> wrote:
> After thinking about this a bit: probably when running webgl code
> under the playground, I should be hooking into the close event for the
> "popup" containing the canvas and dispose of my webgl constructs.
>
> Conceptually speaking, maybe the browser could do this automatically,
> but even if that doesn't run afoul of some webgl or ecmascript or dom
> standards that sort of thing might be years in the future.
>
> What would a close event handler look like, here? (I just need a
> proof-of-concept with a console.log -- not something which does a
> complete cleanup...) Maybe I can figure this out on my own, but if you
> have a concrete idea of how to implement that abstraction, that would
> be great.
>
> Thanks,
>
> --
> Raul
>
> On Sun, Jan 15, 2023 at 7:52 AM Raul Miller <rauldmil...@gmail.com> wrote:
> >
> > Hmm....
> >
> > I tried the webgl implementation from
> > https://rosettacode.org/wiki/WebGL_rotating_F#J and I got it to work,
> > once.
> >
> > But, closing the webgl subwindow and then trying to run it again did
> > not work (instead, it eventually crashed my browser).
> >
> > I don't know if that's a problem specific to my machine, or if it's a
> > playground issue or a browser issue or whatever else.
> >
> > --
> > Raul
> >
> > On Sun, Jan 15, 2023 at 7:01 AM Joe Bogner <joebog...@gmail.com> wrote:
> > >
> > > >
> > > >
> > > > One alternative here might be to create a webserver in J which
> webview
> > > > interacts with (perhaps a jhs variant, though possibly being run from
> > > > within jqt). This would involve significant overhead but it might
> > > > work...
> > >
> > >
> > > How about the J Playground? I took your code and it was copy/paste to
> make
> > > it run in the J Playground.
> > >
> > >
> > >
> https://jsoftware.github.io/j-playground/bin/html2/#url=https://gist.githubusercontent.com/joebo/6002c573f08b57c279c1203d7f5c4328/raw/038f37e626813cca56c15c8376edc705a9a3c8d1/jplayground%2520webgl
> > >
> > >
> > > It shows the console.log too
> > >
> > > You should be able to use the jdo1() from javascript to interact with J
> > > and (2!:0) from J to interact with javascript. See UI example in the
> > > playground
> > >
> > > If you go this route I'd like to add it back in as a J Playground
> example.
> > > I'm not familiar enough with webgl to make something interesting
> > > ----------------------------------------------------------------------
> > > For information about J forums see http://www.jsoftware.com/forums.htm
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm
>
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm