Cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Accidental quit prevention mechanism

ANSWERED

I know we have the opportunity to save data before quitting app:
    import { me } from "appbit";
    me.onunload = () => {}

but it is a one way call with no return.

 

I had a long term test of my app yesterday and end up with an accidential quit of left button pressing during my sleep (I guess). It is a lap chronograph app with 100 laps data bank and 100 hours total counting time, it should not be quit without a double confirmation from user.

 

I am thinking of a system event which can prevent this.

Best Answer
0 Votes
1 BEST ANSWER

Accepted Solutions

You might be able to listen to events for the BACK button, and stop it exiting the first attempt, but use it wisely. You should always provide users with a way to exit.

 

Something like:

 

 

import document from "document";

document.onkeypress = function(evt) {
  console.log("Key pressed: " + evt.key);
if (evt.key === "back") {
evt.preventDefault();
}
}

 

View best answer in original post

Best Answer
0 Votes
2 REPLIES 2

You might be able to listen to events for the BACK button, and stop it exiting the first attempt, but use it wisely. You should always provide users with a way to exit.

 

Something like:

 

 

import document from "document";

document.onkeypress = function(evt) {
  console.log("Key pressed: " + evt.key);
if (evt.key === "back") {
evt.preventDefault();
}
}

 

Best Answer
0 Votes

Thank you for your prompt reply!

 

Yes, I do test that before without that key line of 

evt.preventDefault();

and leading to a mass, 

🙂

Best Answer
0 Votes