Skip to content

ElectronBrowserWindow

Unofficial

Electron BrowserWindow for creating and managing application windows.

Import:

import type { ElectronBrowserWindow } from '@obsidian-typings/obsidian-catalyst-latest';

Signature:

export class ElectronBrowserWindow

Properties

Property Type Description
accessibleTitle string An alternative title provided only to accessibility tools such as screen readers. This string is not directly visible to users.
autoHideMenuBar boolean Whether the window menu bar should hide itself automatically.
closable boolean Whether the window can be manually closed by user. On Linux the setter is a no-op.
documentEdited boolean Whether the window's document has been edited (macOS only).
excludedFromShownWindowsMenu boolean Whether the window is excluded from the application's Windows menu (macOS only).
focusable boolean Whether the window is focusable (macOS and Windows).
fullScreen boolean Whether the window is in fullscreen mode.
fullScreenable boolean Whether the maximize/zoom window button toggles fullscreen mode or maximizes the window.
id number The unique identifier of the window, unique among all BrowserWindow instances of the entire application.
kiosk boolean Whether the window is in kiosk mode.
maximizable boolean Whether the window can be manually maximized by user. On Linux the setter is a no-op.
menuBarVisible boolean Whether the menu bar should be visible (Windows and Linux).
minimizable boolean Whether the window can be manually minimized by user. On Linux the setter is a no-op.
movable boolean Whether the window can be moved by user. On Linux the setter is a no-op.
representedFilename string The pathname of the file the window represents (macOS only).
resizable boolean Whether the window can be manually resized by user.
shadow boolean Whether the window has a shadow.
simpleFullScreen boolean Whether the window is in simple (pre-Lion) fullscreen mode.
title string The title of the native window.
visibleOnAllWorkspaces boolean Whether the window is visible on all workspaces. Always returns false on Windows.
webContents ElectronWebContents The web contents owned by this window. All web page related events and operations will be done via it.

Methods

Method Returns Description
addBrowserView(browserView) void Replacement API for setBrowserView supporting work with multi browser views.
addListener(event, listener) this Registers a listener for the given window event.
addListener(event, listener) this
addListener(event, listener) this
addListener(event, listener) this
addListener(event, listener) this
addListener(event, listener) this
addListener(event, listener) this
addListener(event, listener) this
addListener(event, listener) this
addListener(event, listener) this
addListener(event, listener) this
addListener(event, listener) this
addListener(event, listener) this
addListener(event, listener) this
addListener(event, listener) this
addListener(event, listener) this
addListener(event, listener) this
addListener(event, listener) this
addListener(event, listener) this
addListener(event, listener) this
addListener(event, listener) this
addListener(event, listener) this
addListener(event, listener) this
addListener(event, listener) this
addListener(event, listener) this
addListener(event, listener) this
addListener(event, listener) this
addListener(event, listener) this
addListener(event, listener) this
addListener(event, listener) this
addListener(event, listener) this
addListener(event, listener) this
addListener(event, listener) this
addListener(event, listener) this
addListener(event, listener) this
addListener(event, listener) this
addTabbedWindow(browserWindow) void Adds a window as a tab on this window, after the tab for the window instance (macOS only).
blur() void Removes focus from the window.
blurWebView() void Removes focus from the web view.
capturePage(rect?) Promise<ElectronNativeImage> Captures a snapshot of the page within rect. Omitting rect will capture the whole visible page.
center() void Moves window to the center of the screen.
close() void Tries to close the window. This has the same effect as a user manually clicking the close button.
closeFilePreview() void Closes the currently open Quick Look panel (macOS only).
destroy() void Force-closes the window; the unload and beforeunload events won't be emitted, but closed is guaranteed.
flashFrame(flag) void Starts or stops flashing the window to attract user's attention.
focus() void Focuses on the window.
focusOnWebView() void Focuses on the web view.
fromBrowserView(browserView) ElectronBrowserWindow | null Returns the window that owns the given browserView.
fromId(id) ElectronBrowserWindow | null Returns the window with the given id.
fromWebContents(webContents) ElectronBrowserWindow | null Returns the window that owns the given webContents.
getAllWindows() ElectronBrowserWindow[] Returns all opened browser windows.
getBackgroundColor() string Returns the background color of the window in Hex (#RRGGBB) format.
getBounds() ElectronRectangle Returns the bounds of the window.
getBrowserView() ElectronBrowserView | null Returns the BrowserView attached to this window.
getBrowserViews() ElectronBrowserView[] Returns all views attached with addBrowserView or setBrowserView.
getChildWindows() ElectronBrowserWindow[] Returns all child windows.
getContentBounds() ElectronRectangle Returns the bounds of the window's client area.
getContentSize() number[] Returns the window's client area's width and height.
getFocusedWindow() ElectronBrowserWindow | null Returns the window that is focused in this application.
getMaximumSize() number[] Returns the window's maximum width and height.
getMediaSourceId() string Returns the window id in the format of DesktopCapturerSource's id.
getMinimumSize() number[] Returns the window's minimum width and height.
getNativeWindowHandle() Buffer Returns the platform-specific handle of the window.
getNormalBounds() ElectronRectangle Returns the window bounds of the normal state, regardless of the current window state.
getOpacity() number Returns the opacity of the window, between 0.0 (fully transparent) and 1.0 (fully opaque). On Linux, always returns 1.
getParentWindow() ElectronBrowserWindow | null Returns the parent window.
getPosition() number[] Returns the window's current position.
getRepresentedFilename() string Returns the pathname of the file the window represents (macOS only).
getSize() number[] Returns the window's width and height.
getTitle() string Returns the title of the native window.
getTrafficLightPosition() ElectronPoint Returns the custom position for the traffic light buttons in a frameless window (macOS only).
hasShadow() boolean Returns whether the window has a shadow.
hide() void Hides the window.
hookWindowMessage(message, callback) void Hooks a windows message. The callback is called when the message is received in the WndProc (Windows only).
isAlwaysOnTop() boolean Returns whether the window is always on top of other windows.
isClosable() boolean Returns whether the window can be manually closed by user. On Linux always returns true (macOS and Windows).
isDestroyed() boolean Returns whether the window has been destroyed.
isDocumentEdited() boolean Returns whether the window's document has been edited (macOS only).
isEnabled() boolean Returns whether the window is enabled.
isFocusable() void Returns whether the window can be focused (macOS and Windows).
isFocused() boolean Returns whether the window is focused.
isFullScreen() boolean Returns whether the window is in fullscreen mode.
isFullScreenable() boolean Returns whether the maximize/zoom window button toggles fullscreen mode or maximizes the window.
isKiosk() boolean Returns whether the window is in kiosk mode.
isMaximizable() boolean Returns whether the window can be manually maximized by user. On Linux always returns true (macOS and Windows).
isMaximized() boolean Returns whether the window is maximized.
isMenuBarAutoHide() boolean Returns whether the menu bar automatically hides itself.
isMenuBarVisible() boolean Returns whether the menu bar is visible.
isMinimizable() boolean Returns whether the window can be manually minimized by user. On Linux always returns true (macOS and Windows).
isMinimized() boolean Returns whether the window is minimized.
isModal() boolean Returns whether the current window is a modal window.
isMovable() boolean Returns whether the window can be moved by user. On Linux always returns true (macOS and Windows).
isNormal() boolean Returns whether the window is in normal state (not maximized, not minimized, not in fullscreen mode).
isResizable() boolean Returns whether the window can be manually resized by user.
isSimpleFullScreen() boolean Returns whether the window is in simple (pre-Lion) fullscreen mode (macOS only).
isTabletMode() boolean Returns whether the window is in Windows 10 tablet mode (Windows only).
isVisible() boolean Returns whether the window is visible to the user.
isVisibleOnAllWorkspaces() boolean Returns whether the window is visible on all workspaces. Always returns false on Windows.
isWindowMessageHooked(message) boolean Returns whether the message is hooked (Windows only).
loadFile(filePath, options?) Promise<void> Loads a file into the window. Same as webContents.loadFile.
loadURL(url, options?) Promise<void> Loads a URL into the window. Same as webContents.loadURL.
maximize() void Maximizes the window. This will also show (but not focus) the window if it isn't being displayed already.
mergeAllWindows() void Merges all windows into one window with multiple tabs when native tabs are enabled (macOS only).
minimize() void Minimizes the window. On some platforms the minimized window will be shown in the Dock.
moveAbove(mediaSourceId) void Moves window above the source window in the sense of z-order.
moveTabToNewWindow() void Moves the current tab into a new window if native tabs are enabled and there is more than one tab (macOS only).
moveTop() void Moves window to top (z-order) regardless of focus.
on('always-on-top-changed', listener) this Registers a listener for the given window event.
on('app-command', listener) this
on('blur', listener) this
on('close', listener) this
on('closed', listener) this
on('enter-full-screen', listener) this
on('enter-html-full-screen', listener) this
on('focus', listener) this
on('hide', listener) this
on('leave-full-screen', listener) this
on('leave-html-full-screen', listener) this
on('maximize', listener) this
on('minimize', listener) this
on('move', listener) this
on('moved', listener) this
on('new-window-for-tab', listener) this
on('page-title-updated', listener) this
on('ready-to-show', listener) this
on('resize', listener) this
on('resized', listener) this
on('responsive', listener) this
on('restore', listener) this
on('rotate-gesture', listener) this
on('scroll-touch-begin', listener) this
on('scroll-touch-edge', listener) this
on('scroll-touch-end', listener) this
on('session-end', listener) this
on('sheet-begin', listener) this
on('sheet-end', listener) this
on('show', listener) this
on('swipe', listener) this
on('system-context-menu', listener) this
on('unmaximize', listener) this
on('unresponsive', listener) this
on('will-move', listener) this
on('will-resize', listener) this
once(event, listener) this Registers a one-time listener for the given window event.
once(event, listener) this
once(event, listener) this
once(event, listener) this
once(event, listener) this
once(event, listener) this
once(event, listener) this
once(event, listener) this
once(event, listener) this
once(event, listener) this
once(event, listener) this
once(event, listener) this
once(event, listener) this
once(event, listener) this
once(event, listener) this
once(event, listener) this
once(event, listener) this
once(event, listener) this
once(event, listener) this
once(event, listener) this
once(event, listener) this
once(event, listener) this
once(event, listener) this
once(event, listener) this
once(event, listener) this
once(event, listener) this
once(event, listener) this
once(event, listener) this
once(event, listener) this
once(event, listener) this
once(event, listener) this
once(event, listener) this
once(event, listener) this
once(event, listener) this
once(event, listener) this
once(event, listener) this
previewFile(path, displayName?) void Uses Quick Look to preview a file at a given path (macOS only).
reload() void Reloads the current page. Same as webContents.reload.
removeBrowserView(browserView) void Removes a view added with addBrowserView or setBrowserView.
removeListener(event, listener) this Removes a listener for the given window event.
removeListener(event, listener) this
removeListener(event, listener) this
removeListener(event, listener) this
removeListener(event, listener) this
removeListener(event, listener) this
removeListener(event, listener) this
removeListener(event, listener) this
removeListener(event, listener) this
removeListener(event, listener) this
removeListener(event, listener) this
removeListener(event, listener) this
removeListener(event, listener) this
removeListener(event, listener) this
removeListener(event, listener) this
removeListener(event, listener) this
removeListener(event, listener) this
removeListener(event, listener) this
removeListener(event, listener) this
removeListener(event, listener) this
removeListener(event, listener) this
removeListener(event, listener) this
removeListener(event, listener) this
removeListener(event, listener) this
removeListener(event, listener) this
removeListener(event, listener) this
removeListener(event, listener) this
removeListener(event, listener) this
removeListener(event, listener) this
removeListener(event, listener) this
removeListener(event, listener) this
removeListener(event, listener) this
removeListener(event, listener) this
removeListener(event, listener) this
removeListener(event, listener) this
removeListener(event, listener) this
removeMenu() void Removes the window's menu bar (Linux and Windows).
restore() void Restores the window from minimized state to its previous state.
selectNextTab() void Selects the next tab when native tabs are enabled and there are other tabs in the window (macOS only).
selectPreviousTab() void Selects the previous tab when native tabs are enabled and there are other tabs in the window (macOS only).
setAlwaysOnTop(flag, level?, relativeLevel?) void Sets whether the window should show always on top of other windows.
setAppDetails(options) void Sets the properties for the window's taskbar button (Windows only).
setAspectRatio(aspectRatio, extraSize?) void Makes the window maintain an aspect ratio.
setAutoHideCursor(autoHide) void Controls whether to hide the cursor when typing (macOS only).
setAutoHideMenuBar(hide) void Sets whether the window menu bar should hide itself automatically.
setBackgroundColor(backgroundColor) void Sets the background color of the window.
setBounds(bounds, animate?) void Resizes and moves the window to the supplied bounds. Any properties not supplied default to their current values.
setBrowserView(browserView) void Sets the view attached to the window.
setClosable(closable) void Sets whether the window can be manually closed by user. On Linux does nothing (macOS and Windows).
setContentBounds(bounds, animate?) void Resizes and moves the window's client area to the supplied bounds.
setContentProtection(enable) void Prevents the window contents from being captured by other apps (macOS and Windows).
setContentSize(width, height, animate?) void Resizes the window's client area to width and height.
setDocumentEdited(edited) void Specifies whether the window's document has been edited (macOS only).
setEnabled(enable) void Disables or enables the window.
setFocusable(focusable) void Changes whether the window can be focused (macOS and Windows).
setFullScreen(flag) void Sets whether the window should be in fullscreen mode.
setFullScreenable(fullscreenable) void Sets whether the maximize/zoom window button toggles fullscreen mode or maximizes the window.
setHasShadow(hasShadow) void Sets whether the window should have a shadow.
setIcon(icon) void Changes the window icon (Linux and Windows).
setIgnoreMouseEvents(ignore, options?) void Makes the window ignore all mouse events.
setKiosk(flag) void Enters or leaves kiosk mode.
setMaximizable(maximizable) void Sets whether the window can be manually maximized by user. On Linux does nothing (macOS and Windows).
setMaximumSize(width, height) void Sets the maximum size of the window.
setMenu(menu) void Sets the menu as the window's menu bar (Linux and Windows).
setMenuBarVisibility(visible) void Sets whether the menu bar should be visible (Linux and Windows).
setMinimizable(minimizable) void Sets whether the window can be manually minimized by user. On Linux does nothing (macOS and Windows).
setMinimumSize(width, height) void Sets the minimum size of the window.
setMovable(movable) void Sets whether the window can be moved by user. On Linux does nothing (macOS and Windows).
setOpacity(opacity) void Sets the opacity of the window. On Linux, does nothing. Out of bound values are clamped to the [0, 1] range.
setOverlayIcon(overlay, description) void Sets a 16 x 16 pixel overlay onto the current taskbar icon (Windows only).
setParentWindow(parent) void Sets the parent window. Passing null will turn the current window into a top-level window.
setPosition(x, y, animate?) void Moves the window to x and y.
setProgressBar(progress, options?) void Sets the progress value in the progress bar. Valid range is [0, 1.0].
setRepresentedFilename(filename) void Sets the pathname of the file the window represents (macOS only).
setResizable(resizable) void Sets whether the window can be manually resized by user.
setShape(rects) void Sets a window shape determining the area within the window where drawing and user interaction are permitted (Linux and Windows).
setSheetOffset(offsetY, offsetX?) void Changes the attachment point for sheets on macOS (macOS only).
setSimpleFullScreen(flag) void Enters or leaves simple fullscreen mode (macOS only).
setSize(width, height, animate?) void Resizes the window to width and height.
setSkipTaskbar(skip) void Makes the window not show in the taskbar.
setThumbarButtons(buttons) boolean Adds a thumbnail toolbar with a specified set of buttons to the thumbnail image of a window (Windows only).
setThumbnailClip(region) void Sets the region of the window to show as the thumbnail image displayed when hovering over the window in the taskbar (Windows only).
setThumbnailToolTip(toolTip) void Sets the tooltip displayed when hovering over the window thumbnail in the taskbar (Windows only).
setTitle(title) void Changes the title of the native window.
setTitleBarOverlay(options) void On a window with Window Controls Overlay already enabled, updates the style of the title bar overlay (Windows only).
setTopBrowserView(browserView) void Raises browserView above other views attached to the window.
setTouchBar(touchBar) void Sets the touch bar layout for the current window. Specifying null or undefined clears the touch bar (macOS only).
setTrafficLightPosition(position) void Sets a custom position for the traffic light buttons in a frameless window (macOS only).
setVibrancy(type) void Adds a vibrancy effect to the browser window. Passing null or an empty string removes the effect (macOS only).
setVisibleOnAllWorkspaces(visible, options?) void Sets whether the window should be visible on all workspaces. Does nothing on Windows.
setWindowButtonVisibility(visible) void Sets whether the window traffic light buttons should be visible (macOS only).
show() void Shows and gives focus to the window.
showDefinitionForSelection() void Shows the definition for the selected word (macOS only). Same as webContents.showDefinitionForSelection().
showInactive() void Shows the window but doesn't focus on it.
toggleTabBar() void Toggles the visibility of the tab bar if native tabs are enabled and there is only one tab (macOS only).
unhookAllWindowMessages() void Unhooks all of the window messages (Windows only).
unhookWindowMessage(message) void Unhooks the window message (Windows only).
unmaximize() void Unmaximizes the window.

Links to this page: