Skip to content

Commit a867f23

Browse files
Merge pull request #429 from kdlslyv/master
Add BrowserWindow.GetNativeWindowHandle()
2 parents 8c8115f + 490440c commit a867f23

File tree

4 files changed

+29
-1
lines changed

4 files changed

+29
-1
lines changed

ElectronNET.API/BrowserWindow.cs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1809,6 +1809,25 @@ public Task<bool> IsKioskAsync()
18091809
return taskCompletionSource.Task;
18101810
}
18111811

1812+
/// <summary>
1813+
/// Returns the native type of the handle is HWND on Windows, NSView* on macOS, and Window (unsigned long) on Linux.
1814+
/// </summary>
1815+
/// <returns>string of the native handle obtained, HWND on Windows, NSView* on macOS, and Window (unsigned long) on Linux.</returns>
1816+
public Task<string> GetNativeWindowHandle()
1817+
{
1818+
var taskCompletionSource = new TaskCompletionSource<string>();
1819+
1820+
BridgeConnector.Socket.On("browserWindow-getNativeWindowHandle-completed", (nativeWindowHandle) =>
1821+
{
1822+
BridgeConnector.Socket.Off("browserWindow-getNativeWindowHandle-completed");
1823+
taskCompletionSource.SetResult(nativeWindowHandle.ToString());
1824+
});
1825+
1826+
BridgeConnector.Socket.Emit("browserWindowGetNativeWindowHandle", Id);
1827+
1828+
return taskCompletionSource.Task;
1829+
}
1830+
18121831
/// <summary>
18131832
/// Sets the pathname of the file the window represents,
18141833
/// and the icon of the file will show in window’s title bar.

ElectronNET.Host/api/browserWindows.js

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

0 commit comments

Comments
 (0)