[feat] [v2] How to create a child web view
Describe the problem
In v1, I made a child webview as below.
#[cfg(target_os = "macos")]
let _ = child_window.parent_window(main_window.ns_window().unwrap());
#[cfg(windows)]
let _ = child_window.owner_window(main_window.hwnd().unwrap());
In v2, I think I can make it using the parent method. But it doesn't seem to work in a Windows environment. And, it seems that the method used in v1 is no longer available. Is that right?
Also, I found add_child, which is currently an unstable function. However, this API does not support some of the methods that were previously supported by webviewWindows using Window and Webview. (For example, create a window border when creating webview.)
I'm using v2 and still want to create a child webview in a windows environment. Is add_child the only way?
Describe the solution you'd like
Alternatives considered
No response
Additional context
No response
In v2, I think I can make it using the parent method. But it doesn't seem to work in a Windows environment. And, it seems that the method used in v1 is no longer available. Is that right?
owner_window have been renamed to just owner, seems like the documentation for Windows have failed to build but it exists.
You can still use parent method which is more cross-platform, not sure how is it not working for you, could you explain more? and provide a minimal repro
@amrbashir https://github.com/gusxodnjs/tauri-issues/tree/bug/parent-window
In Windows, the web views created by the parent method act like separate web views. Is there something I missed?
-
macos
-
windows
https://github.com/tauri-apps/tauri/assets/27146546/8b65b13e-225a-497d-95f1-5e6ddf59df09
The macOS behavior doesn't have any equivalent on Windows. The nearest thing is Owned windows, which you can read about their behavior here https://learn.microsoft.com/en-us/windows/win32/winmsg/window-features#owned-windows
Closing as this is the intended behavior.
@amrbashir Thank you, but I think users expect the same behavior for each os when using the way the platform provides it. Can't it be abstracted in Tauri even if the specifications are different for each os? Finally, how do I implement macos-like behavior in a v2 window environment? Should I change the location of my child's window directly whenever the location of the parent window changes?
@amrbashir Thank you, but I think users expect the same behavior for each os when using the way the platform provides it. Can't it be abstracted in Tauri even if the specifications are different for each os?
I understand the sentiment but not everything can be abstracted to behave the same on each OS.
Finally, how do I implement macos-like behavior in a v2 window environment? Should I change the location of my child's window directly whenever the location of the parent window changes?
You can try to listen for parent move events and update the child location.
@amrbashir Thank you for your reply.