mirror of
https://github.com/ElectronNET/Electron.NET.git
synced 2026-02-04 05:34:51 +00:00
browserWindowSetParentWindow: Support null parameter
This commit is contained in:
@@ -1140,7 +1140,17 @@ public class BrowserWindow : ApiBase
|
||||
/// passing null will turn current window into a top-level window.
|
||||
/// </summary>
|
||||
/// <param name="parent"></param>
|
||||
public void SetParentWindow(BrowserWindow parent) => this.CallMethod1(JObject.FromObject(parent, _jsonSerializer));
|
||||
public void SetParentWindow(BrowserWindow parent)
|
||||
{
|
||||
if (parent == null)
|
||||
{
|
||||
BridgeConnector.Socket.Emit("browserWindowSetParentWindow", Id, null);
|
||||
}
|
||||
else
|
||||
{
|
||||
BridgeConnector.Socket.Emit("browserWindowSetParentWindow", Id, JObject.FromObject(parent, _jsonSerializer));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The parent window.
|
||||
|
||||
@@ -721,9 +721,14 @@ export = (socket: Socket, app: Electron.App) => {
|
||||
});
|
||||
|
||||
socket.on('browserWindowSetParentWindow', (id, parent) => {
|
||||
const child = getWindowById(id);
|
||||
if (!parent) {
|
||||
// Clear parent: make this window top-level
|
||||
child.setParentWindow(null);
|
||||
return;
|
||||
}
|
||||
const browserWindow = BrowserWindow.fromId(parent.id);
|
||||
|
||||
getWindowById(id).setParentWindow(browserWindow);
|
||||
child.setParentWindow(browserWindow);
|
||||
});
|
||||
|
||||
socket.on('browserWindowGetParentWindow', (id) => {
|
||||
|
||||
Reference in New Issue
Block a user