I have a web application currently running in Electron and would like to move it to Wry/Tauri for opening speed.
The application uses window.resizeTo
to change the window size in real time.
I have tried using the same command with Wry/Tauri, but it does not work.
Is it possible to intercept such a call and act correctly?
Asked
Active
Viewed 250 times
-1

TheGr8_Nik
- 3,080
- 4
- 18
- 33
1 Answers
0
Maybe will be useful for someone other. I figured out that it is possible to use webview.evaluate_script('<js code>')
to inject some code in opened page.
Thus it's possible to change the default window.resizeTo
functionallity to something I need to, for example for my needs I can do:
window.resizeTo = (w, h) => window.ipc.postMessage(`resize,${w},${h}`);
On the WRY
side I can use with_ipc_handler
to resize the window as requested.
WebViewBuilder::new()
.with_ipc_handler(|win, msg| {
let (w, h) = parse_resize_msg(&msg).unwrap();
win.set_inner_size(LogicalSize::new(w, h)).unwrap();
})
.build()?;

TheGr8_Nik
- 3,080
- 4
- 18
- 33