web-view
web-view copied to clipboard
Handle window buttons, esp. close.
It would be nice if you could intercept and handle the window buttons so you can do things like confirm, show save progress while closing, or save window position - this might be something I'm missing (something with onunload in the view?) in which case this might just be a doc bug.
If this isn't currently possible, the simplest option might be to forward them into the JS like host calls, otherwise it looks like it might be a API breaking change in WebViewBuilder to add more fields.
The title bar is handled by the respective gui apis, winapi for windows, gtk for linux and i guess cocoa? for macOS.
You could in theory do one of two things,
- modify webview itself, in src/lib.rs
/// Gracefully exits the webview
pub fn exit(&mut self) {
\\ Use tinyfiledialog to execute a confirm window?
unsafe { webview_exit(self.inner.unwrap()) }
}
- Implement a custom title bar, using my fork of webview https://github.com/Blakeinstein/web-view it has exit, minimize, maximize function calls for both gtk and edge, and window drag for edge only, as of now.
I'm running into the same issue with handling the window closing. Did you manage to handle this situation @simonbuchan? Did you modify webview exit function as suggested or something different?
We switched to Tauri.
How difficult was that switch? Would you recommend that? @simonbuchan
Well it's a whole different thing, much more of an application framework controlling your build etc., but it's quite nicely designed.
If you just want a webview, the WRY crate that they spun out might be enough.
How difficult was that switch? Would you recommend that? @simonbuchan
I know you didn't ask me. But I would still like to pitch in. Even I switched to Tauri, for what I was using this project for. And for me it was relatively straightforward. Infact I was able to additionally simplify my frontend pipeline, which I had to add inorder to fit in with the restrictions here.