Skip to content

Commit 709780f

Browse files
Merge pull request #673 from MutatedGamer/parentOption
Add ability to set a window's parent using BrowserWindowOptions
2 parents 9a17d22 + 4a44f3e commit 709780f

File tree

3 files changed

+16
-3
lines changed

3 files changed

+16
-3
lines changed

ElectronNET.API/Entities/BrowserWindowOptions.cs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -154,14 +154,14 @@ public class BrowserWindowOptions
154154
public bool Frame { get; set; } = true;
155155

156156
/// <summary>
157-
/// Whether this is a modal window. This only works when the window is a child
158-
/// window.Default is false.
157+
/// Whether this is a modal window. This only works when <see cref="Parent"/> is
158+
/// also specified. Default is false.
159159
/// </summary>
160160
public bool Modal { get; set; }
161161

162162
/// <summary>
163163
/// Whether the web view accepts a single mouse-down event that simultaneously
164-
/// activates the window.Default is false.
164+
/// activates the window. Default is false.
165165
/// </summary>
166166
public bool AcceptFirstMouse { get; set; }
167167

@@ -270,5 +270,11 @@ public class BrowserWindowOptions
270270
/// These will only be used if the Proxy field is also set.
271271
/// </summary>
272272
public string ProxyCredentials { get; set; }
273+
274+
/// <summary>
275+
/// The window to use as the created window's parent.
276+
/// </summary>
277+
[DefaultValue(null)]
278+
public BrowserWindow Parent { get; set; }
273279
}
274280
}

ElectronNET.Host/api/browserWindows.js

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

ElectronNET.Host/api/browserWindows.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,10 @@ export = (socket: Socket, app: Electron.App) => {
216216
options = { ...options, webPreferences: { nodeIntegration: true, contextIsolation: false } };
217217
}
218218

219+
if (options.parent) {
220+
options.parent = BrowserWindow.fromId(options.parent.id);
221+
}
222+
219223
// we dont want to recreate the window when watch is ready.
220224
if (app.commandLine.hasSwitch('watch') && app['mainWindowURL'] === loadUrl) {
221225
window = app['mainWindow'];

0 commit comments

Comments
 (0)