Title: GBC window closed event handler Post by: Francois G. on February 15, 2024, 04:23:02 pm Hi,
Targeting Genero 4.01 GWC via GAS. When writing a simple Hello World GUI with only 1 label ("Hello World"), how can the Google Chrome window.closed / window.closing event ('beforeunload' event) be trapped to tell the 4GL that the web client is closing? Is there a way to add the following javascript to the web page served by the GAS? <script type="text/javascript"> window.addEventListener('beforeunload', function (e) { // Tell the 4GL program that Google Chrome is closing }); </script> Title: Re: GBC window closed event handler Post by: Francois G. on February 15, 2024, 04:33:47 pm I meant GBC, not GWC.
When we use: OPTIONS ON CLOSE APPLICATION CALL end_app upon closing the closing of the entire Google Chrome window, Google Chrome closes immediately, but the 4GL code keeps running until the end_app() function completes. This is mostly good, but is there a way to hold off Google Chrome closing until the 4GL completes? Also when the tab is closed, could the same holding off be implemented? Title: Re: GBC window closed event handler Post by: Francois G. on February 15, 2024, 04:40:46 pm Sorry for my typing, I am not used to not being able to correct a post.
When the Google Chrome browser is killed (using the Windows task manager), the 4GL code keeps running (until some sort of GAS timeout, where the VM gets killed). Is there a way to get the 4GL pre-notified before the VM gets killed by the GAS? Title: Re: GBC window closed event handler Post by: Francois G. on February 15, 2024, 04:50:32 pm We have been reading the "Front-end termination" page of the manual (https://4js.com/online_documentation/fjs-fgl-manual-html/#fgl-topics/c_fgl_programs_010.html) so we mostly understand how 4GL generally handles that
Title: Re: GBC window closed event handler Post by: Olivier E. on February 15, 2024, 05:18:23 pm Hi François,
Does the following "Ask-Reuben" topics answer your questions? https://4js.com/ask-reuben/ig-74/ https://4js.com/ask-reuben/ig-176/ Olivier Title: Re: GBC window closed event handler Post by: Francois G. on February 15, 2024, 05:25:18 pm Thanks Olivier,
Useful information indeed. We will run some experiments and see how we can cleanly terminate the entire process tree of our 4GL app (which itself has called many sub-processes, which also need to be cleanly terminated). Title: Re: GBC window closed event handler Post by: Anthony L. on February 23, 2024, 09:42:39 am Hi, In your GBC application, you can include the following JavaScript snippet to detect when the user is closing the browser window:Targeting Genero 4.01 GWC via GAS. When writing a simple Hello World GUI with only 1 label ("Hello World"), how can the Google Chrome window.closed / window.closing event ('beforeunload' event) be trapped to tell the 4GL that the web client is closing? Is there a way to add the following javascript to the web page served by the GAS? <script type="text/javascript"> uno online (https://uno-online.io) window.addEventListener('beforeunload', function (e) { // Tell the 4GL program that Google Chrome is closing }); </script> JavaScript <script type="text/javascript"> window.addEventListener('beforeunload', function (e) { // Your custom logic here // For example, notify the 4GL program that Google Chrome is closing }); </script> Replace the comment with the specific action you want to take when the user closes the window. I hope it can help. Title: Re: GBC window closed event handler Post by: Francois G. on February 23, 2024, 09:57:49 am Thanks Anthony,
this was my starting point, what I had already done. I wanted to know the next step, which apparently are not possible, or not advisable, but instead the answer lies in the Ask Reuben post https://4js.com/ask-reuben/ig-74/ which I have now implemented. I will still need to read up on how to code the front-end of a GBC application, but that is a question for another time. Regards, |