BrowserWindow

Constructors

Link copied to clipboard
constructor(options: BrowserWindowConstructorOptions = definedExternally)

BrowserWindow

Types

Link copied to clipboard
object Companion

Properties

Link copied to clipboard

A string property that defines an alternative title provided only to accessibility tools such as screen readers. This string is not directly visible to users.

Link copied to clipboard
Link copied to clipboard

A boolean property that determines whether the window menu bar should hide itself automatically. Once set, the menu bar will only show when users press the single Alt key.

Link copied to clipboard
Link copied to clipboard

A boolean property that determines whether the window can be manually closed by user.

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard

A boolean property that specifies whether the window’s document has been edited.

Link copied to clipboard

A boolean property that determines whether the window is excluded from the application’s Windows menu. false by default.

Link copied to clipboard

A boolean property that determines whether the window is focusable.

Link copied to clipboard
Link copied to clipboard

A boolean property that determines whether the window is in fullscreen mode.

Link copied to clipboard

A boolean property that determines whether the maximize/zoom window button toggles fullscreen mode or maximizes the window.

Link copied to clipboard
Link copied to clipboard
val id: Double

A Integer property representing the unique ID of the window. Each ID is unique among all BrowserWindow instances of the entire Electron application.

Link copied to clipboard

A boolean property that determines whether the window is in kiosk mode.

Link copied to clipboard

A boolean property that determines whether the window can be manually maximized by user.

Link copied to clipboard
Link copied to clipboard

A boolean property that determines whether the menu bar should be visible.

Link copied to clipboard

A boolean property that determines whether the window can be manually minimized by user.

Link copied to clipboard
Link copied to clipboard

A boolean property that determines Whether the window can be moved by user.

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard

A string property that determines the pathname of the file the window represents, and the icon of the file will show in window's title bar.

Link copied to clipboard

A boolean property that determines whether the window can be manually resized by user.

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard

A boolean property that determines whether the window has a shadow.

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard

A boolean property that determines whether the window is in simple (pre-Lion) fullscreen mode.

Link copied to clipboard
Link copied to clipboard

A string (optional) property that is equal to the tabbingIdentifier passed to the BrowserWindow constructor or undefined if none was set.

Link copied to clipboard

A string property that determines the title of the native window.

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard

A boolean property that determines whether the window is visible on all workspaces.

Link copied to clipboard

A WebContents object this window owns. All web page related events and operations will be done via it.

Link copied to clipboard

Functions

Link copied to clipboard
fun addBrowserView(browserView: BrowserView)

Replacement API for setBrowserView supporting work with multi browser views.

Link copied to clipboard
fun addTabbedWindow(browserWindow: BrowserWindow)

Adds a window as a tab on this window, after the tab for the window instance.

Link copied to clipboard
fun blur()

Removes focus from the window.

Link copied to clipboard
Link copied to clipboard
fun capturePage(rect: Rectangle = definedExternally, opts: Opts = definedExternally): Promise<NativeImage>

Resolves with a NativeImage

Link copied to clipboard
fun center()

Moves window to the center of the screen.

Link copied to clipboard
fun close()

Try to close the window. This has the same effect as a user manually clicking the close button of the window. The web page may cancel the close though. See the close event.

Link copied to clipboard

Closes the currently open Quick Look panel.

Link copied to clipboard
fun destroy()

Force closing the window, the unload and beforeunload event won't be emitted for the web page, and close event will also not be emitted for this window, but it guarantees the closed event will be emitted.

Link copied to clipboard
Link copied to clipboard
fun flashFrame(flag: Boolean)

Starts or stops flashing the window to attract user's attention.

Link copied to clipboard
fun focus()

Focuses on the window.

Link copied to clipboard
Link copied to clipboard

Gets the background color of the window in Hex (#RRGGBB) format.

Link copied to clipboard

The bounds of the window as Object.

Link copied to clipboard

The BrowserView attached to win. Returns null if one is not attached. Throws an error if multiple BrowserViews are attached.

Link copied to clipboard

a sorted by z-index array of all BrowserViews that have been attached with addBrowserView or setBrowserView. The top-most BrowserView is the last element of the array.

Link copied to clipboard

All child windows.

Link copied to clipboard

The bounds of the window's client area as Object.

Link copied to clipboard

Contains the window's client area's width and height.

Link copied to clipboard

Contains the window's maximum width and height.

Link copied to clipboard
Link copied to clipboard

Window id in the format of DesktopCapturerSource's id. For example "window:1324:0".

Link copied to clipboard

Contains the window's minimum width and height.

Link copied to clipboard

The platform-specific handle of the window.

Link copied to clipboard

Contains the window bounds of the normal state

Link copied to clipboard

between 0.0 (fully transparent) and 1.0 (fully opaque). On Linux, always returns

Link copied to clipboard

The parent window or null if there is no parent.

Link copied to clipboard

Contains the window's current position.

Link copied to clipboard

The pathname of the file the window represents.

Link copied to clipboard

Contains the window's width and height.

Link copied to clipboard

The title of the native window.

Link copied to clipboard

The custom position for the traffic light buttons in frameless window, null will be returned when there is no custom position.

Link copied to clipboard

Whether the window has a shadow.

Link copied to clipboard
fun hide()

Hides the window.

Link copied to clipboard
fun hookWindowMessage(message: Double, callback: (wParam: Buffer, lParam: Buffer) -> Unit)

Hooks a windows message. The callback is called when the message is received in the WndProc.

Link copied to clipboard

Invalidates the window shadow so that it is recomputed based on the current window shape.

Link copied to clipboard

Whether the window is always on top of other windows.

Link copied to clipboard

Whether the window can be manually closed by user.

Link copied to clipboard

Whether the window is destroyed.

Link copied to clipboard

Whether the window's document has been edited.

Link copied to clipboard

whether the window is enabled.

Link copied to clipboard

Whether the window can be focused.

Link copied to clipboard

Whether the window is focused.

Link copied to clipboard

Whether the window is in fullscreen mode.

Link copied to clipboard

Whether the maximize/zoom window button toggles fullscreen mode or maximizes the window.

Link copied to clipboard

Whether the window will be hidden when the user toggles into mission control.

Link copied to clipboard

Whether the window is in kiosk mode.

Link copied to clipboard

Whether the window can be manually maximized by user.

Link copied to clipboard

Whether the window is maximized.

Link copied to clipboard

Whether menu bar automatically hides itself.

Link copied to clipboard

Whether the menu bar is visible.

Link copied to clipboard

Whether the window can be manually minimized by the user.

Link copied to clipboard

Whether the window is minimized.

Link copied to clipboard

Whether current window is a modal window.

Link copied to clipboard

Whether the window can be moved by user.

Link copied to clipboard

Whether the window is in normal state (not maximized, not minimized, not in fullscreen mode).

Link copied to clipboard

Whether the window can be manually resized by the user.

Link copied to clipboard

Whether the window is in simple (pre-Lion) fullscreen mode.

Link copied to clipboard

Whether the window is in Windows 10 tablet mode.

Link copied to clipboard

Whether the window is visible to the user in the foreground of the app.

Link copied to clipboard

Whether the window is visible on all workspaces.

Link copied to clipboard

true or false depending on whether the message is hooked.

Link copied to clipboard
fun loadFile(filePath: String, options: LoadFileOptions = definedExternally): Promise<Void>

the promise will resolve when the page has finished loading (see did-finish-load), and rejects if the page fails to load (see did-fail-load).

Link copied to clipboard
fun loadURL(url: String, options: LoadURLOptions = definedExternally): Promise<Void>

the promise will resolve when the page has finished loading (see did-finish-load), and rejects if the page fails to load (see did-fail-load).

Link copied to clipboard
fun maximize()

Maximizes the window. This will also show (but not focus) the window if it isn't being displayed already.

Link copied to clipboard

Merges all windows into one window with multiple tabs when native tabs are enabled and there is more than one open window.

Link copied to clipboard
fun minimize()

Minimizes the window. On some platforms the minimized window will be shown in the Dock.

Link copied to clipboard
fun moveAbove(mediaSourceId: String)

Moves window above the source window in the sense of z-order. If the mediaSourceId is not of type window or if the window does not exist then this method throws an error.

Link copied to clipboard

Moves the current tab into a new window if native tabs are enabled and there is more than one tab in the current window.

Link copied to clipboard
fun moveTop()

Moves window to top(z-order) regardless of focus

Link copied to clipboard
fun previewFile(path: String, displayName: String = definedExternally)

Uses Quick Look to preview a file at a given path.

Link copied to clipboard
fun reload()

Same as webContents.reload.

Link copied to clipboard
fun removeBrowserView(browserView: BrowserView)
Link copied to clipboard

Remove the window's menu bar.

Link copied to clipboard
fun restore()

Restores the window from minimized state to its previous state.

Link copied to clipboard

Selects the next tab when native tabs are enabled and there are other tabs in the window.

Link copied to clipboard

Selects the previous tab when native tabs are enabled and there are other tabs in the window.

Link copied to clipboard
fun setAlwaysOnTop(flag: Boolean, level: BrowserWindowSetAlwaysOnTopLevel = definedExternally, relativeLevel: Double = definedExternally)

Sets whether the window should show always on top of other windows. After setting this, the window is still a normal window, not a toolbox window which can not be focused on.

Link copied to clipboard

Sets the properties for the window's taskbar button.

Link copied to clipboard
fun setAspectRatio(aspectRatio: Double, extraSize: Size = definedExternally)

This will make a window maintain an aspect ratio. The extra size allows a developer to have space, specified in pixels, not included within the aspect ratio calculations. This API already takes into account the difference between a window's size and its content size.

Link copied to clipboard
fun setAutoHideCursor(autoHide: Boolean)

Controls whether to hide cursor when typing.

Link copied to clipboard

Sets whether the window menu bar should hide itself automatically. Once set the menu bar will only show when users press the single Alt key.

Link copied to clipboard
fun setBackgroundColor(backgroundColor: String)

Examples of valid backgroundColor values:

Link copied to clipboard

This method sets the browser window's system-drawn background material, including behind the non-client area.

Link copied to clipboard
fun setBounds(bounds: Rectangle, animate: Boolean = definedExternally)

Resizes and moves the window to the supplied bounds. Any properties that are not supplied will default to their current values.

Link copied to clipboard
fun setBrowserView(browserView: BrowserView?)
Link copied to clipboard
fun setClosable(closable: Boolean)

Sets whether the window can be manually closed by user. On Linux does nothing.

Link copied to clipboard
fun setContentBounds(bounds: Rectangle, animate: Boolean = definedExternally)

Resizes and moves the window's client area (e.g. the web page) to the supplied bounds.

Link copied to clipboard

Prevents the window contents from being captured by other apps.

Link copied to clipboard
fun setContentSize(width: Double, height: Double, animate: Boolean = definedExternally)

Resizes the window's client area (e.g. the web page) to width and height.

Link copied to clipboard

Specifies whether the window’s document has been edited, and the icon in title bar will become gray when set to true.

Link copied to clipboard
fun setEnabled(enable: Boolean)

Disable or enable the window.

Link copied to clipboard
fun setFocusable(focusable: Boolean)

Changes whether the window can be focused.

Link copied to clipboard

Sets whether the window should be in fullscreen mode.

Link copied to clipboard
fun setFullScreenable(fullscreenable: Boolean)

Sets whether the maximize/zoom window button toggles fullscreen mode or maximizes the window.

Link copied to clipboard
fun setHasShadow(hasShadow: Boolean)

Sets whether the window should have a shadow.

Link copied to clipboard

Sets whether the window will be hidden when the user toggles into mission control.

Link copied to clipboard
fun setIcon(icon: NativeImage)
fun setIcon(icon: String)

Changes window icon.

Link copied to clipboard
fun setIgnoreMouseEvents(ignore: Boolean, options: IgnoreMouseEventsOptions = definedExternally)

Makes the window ignore all mouse events.

Link copied to clipboard
fun setKiosk(flag: Boolean)

Enters or leaves kiosk mode.

Link copied to clipboard
fun setMaximizable(maximizable: Boolean)

Sets whether the window can be manually maximized by user. On Linux does nothing.

Link copied to clipboard
fun setMaximumSize(width: Double, height: Double)

Sets the maximum size of window to width and height.

Link copied to clipboard
Link copied to clipboard
fun setMenu(menu: Menu?)

Sets the menu as the window's menu bar.

Link copied to clipboard

Sets whether the menu bar should be visible. If the menu bar is auto-hide, users can still bring up the menu bar by pressing the single Alt key.

Link copied to clipboard
fun setMinimizable(minimizable: Boolean)

Sets whether the window can be manually minimized by user. On Linux does nothing.

Link copied to clipboard
fun setMinimumSize(width: Double, height: Double)

Sets the minimum size of window to width and height.

Link copied to clipboard
fun setMovable(movable: Boolean)

Sets whether the window can be moved by user. On Linux does nothing.

Link copied to clipboard
fun setOpacity(opacity: Double)

Sets the opacity of the window. On Linux, does nothing. Out of bound number values are clamped to the 0, 1 range.

Link copied to clipboard
fun setOverlayIcon(overlay: NativeImage?, description: String)

Sets a 16 x 16 pixel overlay onto the current taskbar icon, usually used to convey some sort of application status or to passively notify the user.

Link copied to clipboard

Sets parent as current window's parent window, passing null will turn current window into a top-level window.

Link copied to clipboard
fun setPosition(x: Double, y: Double, animate: Boolean = definedExternally)

Moves window to x and y.

Link copied to clipboard
fun setProgressBar(progress: Double, options: ProgressBarOptions = definedExternally)

Sets progress value in progress bar. Valid range is 0, 1.0.

Link copied to clipboard

Sets the pathname of the file the window represents, and the icon of the file will show in window's title bar.

Link copied to clipboard
fun setResizable(resizable: Boolean)

Sets whether the window can be manually resized by the user.

Link copied to clipboard

Setting a window shape determines the area within the window where the system permits drawing and user interaction. Outside of the given region, no pixels will be drawn and no mouse events will be registered. Mouse events outside of the region will not be received by that window, but will fall through to whatever is behind the window.

Link copied to clipboard
fun setSheetOffset(offsetY: Double, offsetX: Double = definedExternally)

Changes the attachment point for sheets on macOS. By default, sheets are attached just below the window frame, but you may want to display them beneath a HTML-rendered toolbar. For example:

Link copied to clipboard

Enters or leaves simple fullscreen mode.

Link copied to clipboard
fun setSize(width: Double, height: Double, animate: Boolean = definedExternally)

Resizes the window to width and height. If width or height are below any set minimum size constraints the window will snap to its minimum size.

Link copied to clipboard

Makes the window not show in the taskbar.

Link copied to clipboard

Whether the buttons were added successfully

Link copied to clipboard

Sets the region of the window to show as the thumbnail image displayed when hovering over the window in the taskbar. You can reset the thumbnail to be the entire window by specifying an empty region: { x: 0, y: 0, width: 0, height: 0 }.

Link copied to clipboard

Sets the toolTip that is displayed when hovering over the window thumbnail in the taskbar.

Link copied to clipboard
fun setTitle(title: String)

Changes the title of native window to title.

Link copied to clipboard

On a Window with Window Controls Overlay already enabled, this method updates the style of the title bar overlay.

Link copied to clipboard
fun setTopBrowserView(browserView: BrowserView)

Raises browserView above other BrowserViews attached to win. Throws an error if browserView is not attached to win.

Link copied to clipboard
fun setTouchBar(touchBar: TouchBar?)

Sets the touchBar layout for the current window. Specifying null or undefined clears the touch bar. This method only has an effect if the machine has a touch bar.

Link copied to clipboard

Adds a vibrancy effect to the browser window. Passing null or an empty string will remove the vibrancy effect on the window.

Link copied to clipboard
fun setVisibleOnAllWorkspaces(visible: Boolean, options: VisibleOnAllWorkspacesOptions = definedExternally)

Sets whether the window should be visible on all workspaces.

Link copied to clipboard

Set a custom position for the traffic light buttons in frameless window. Passing null will reset the position to default.

Link copied to clipboard

Sets whether the window traffic light buttons should be visible.

Link copied to clipboard
fun show()

Shows and gives focus to the window.

Link copied to clipboard

Shows or hides the tab overview when native tabs are enabled.

Link copied to clipboard

Same as webContents.showDefinitionForSelection().

Link copied to clipboard

Shows the window but doesn't focus on it.

Link copied to clipboard

Toggles the visibility of the tab bar if native tabs are enabled and there is only one tab in the current window.

Link copied to clipboard

Unhooks all of the window messages.

Link copied to clipboard

Unhook the window message.

Link copied to clipboard

Unmaximizes the window.