Subscribe for automatic updates: RSS icon RSS

Login icon Sign in for full access | Help icon Help
Advanced search

Pages: [1]
  Reply  |  Print  
Author Topic: GBC window closed event handler  (Read 1227 times)
Francois G.
Posts: 20


« 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>
Francois G.
Posts: 20


« Reply #1 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?
Francois G.
Posts: 20


« Reply #2 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?
Francois G.
Posts: 20


« Reply #3 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
Olivier E.
Four Js
Posts: 199


« Reply #4 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

Francois G.
Posts: 20


« Reply #5 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).
Anthony L.
Posts: 1


« Reply #6 on: February 23, 2024, 09:42:39 am »

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">
uno online
window.addEventListener('beforeunload', function (e) {
  // Tell the 4GL program that Google Chrome is closing
});
</script>

In your GBC application, you can include the following JavaScript snippet to detect when the user is closing the browser window:
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.
Francois G.
Posts: 20


« Reply #7 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,
Pages: [1]
  Reply  |  Print  
 
Jump to:  

Powered by SMF 1.1.21 | SMF © 2015, Simple Machines