os-js / osjs-client

OS.js Client Module
https://manual.os-js.org/
Other
31 stars 31 forks source link

Add a way to stop window destruction #72

Closed RianGallagher closed 5 years ago

RianGallagher commented 5 years ago

At the moment there is no way to stop window destruction from happening after the user has tried to close a window. I think this would be a useful feature to have.

An example use case could be creating a confirmation dialogue when someone tries to close a window and only triggering destruction when they confirm.

andersevenrud commented 5 years ago

I'll add this when I'm home from work :)

andersevenrud commented 5 years ago

If you run npm update @osjs/client and rebuild with npm run build, you can now do the following when making a window:

.createWindow({
   ondestroy: () => {
     return false;
   }
})

The return false will block the destructor method. Any other value here is ignored and will make destruction work as usual.

andersevenrud commented 5 years ago

Since I haven't head back, I'm closing this issue. If you run into any issues, feel free to re-open :)

RianGallagher commented 5 years ago

@andersevenrud thanks for that, it works perfectly

andersevenrud commented 5 years ago

Glad to hear it! :)