Detect if changes are saved!

Instead of always saying
Screenshot 2021-03-31 171139
whenever you try and leave, even if changes are saved, just check if any changes have been made since the last saving, and only if so, popup that alert.

Support! I think this would come in handy just in case something happens.

I don't think you understood the request. The OP is saying that it shouldn't popup the dialog if you already saved. Presently, it already pops up the dialogue no matter what when you go to close it.

Do you agree?

I do agree, and I also think it shouldn't pop up the dialogue if you recently exported some or all blocks or media. Or maybe that would be a setting.

I asked for this a long time ago and Jens told me that it's not possible to make that message conditional on having unsaved edits because it comes from the browser, not from Snap! itself, and you tell the browser to do it when you load a URL (in our case, the Snap! URL).

Well, Scratch can do it.

Okay, I'll ask Jens again...

window.addEventListener('beforeunload', event => {
  if (conditionThatSaysWhetherToShowSaveYourChangesDialog) {
    event.preventDefault();
    event.returnValue = '';
  }
});

support cuz it can be very annoying when I have like, 10 tabs of snap project editing pages and I'm trying to exit all of my snap tabs quickly

No

world.children[0].unsavedChanges()

there is no difference if you use that or not, also I think it's better if you do use it.

It can be better to use it or not use it depending on the circumstances in my opinion. For example, you probably wouldn't type window.world, just world.

It's better here since it specifies what object addEventListener is attaching the event listener to.

ah, ok.

Okay.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.